3D graphics

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...

3D graphics

Postby Stu on Mon Apr 02, 2018 12:32 am

Is there a way in Dyalog to make a surface plot or wire mesh plot?
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: 3D graphics

Postby Adam|Dyalog on Mon Apr 09, 2018 5:42 pm

Sure. Try the following:
      ⎕USING←',system.dll' ',system.drawing.dll' ',sharpplot.dll'
→0/⍨⎕NC'Causeway' ⋄ (System.Drawing←System←Causeway←⎕NS ⍬).⎕CY'sharpplot.dws'
∆sharpplot←⎕NEW Causeway.SharpPlot
∆sharpplot.DrawResponsePlot((⍳100)×↓|1○(0.002×⍳100)∘.×⍳100)⍬ ⍬
∆sharpplot.SaveSvg⊂'/tmp/surface.svg'

And then open /tmp/surface.svg. Try it online!

You can also customise every aspect of the chart:
      Surface;Causeway;System;∆sharpplot
⎕USING←',system.dll' ',system.drawing.dll' ',sharpplot.dll'
:If 0≠⎕NC'Causeway'
(System.Drawing←System←Causeway←⎕NS ⍬).⎕CY'sharpplot.dws'
:EndIf
∆sharpplot←⎕NEW Causeway.SharpPlot
∆sharpplot.SetBackground System.Drawing.Color.Black Causeway.FillStyle.Sunrise 0
∆sharpplot.SetAltitudeColors⊂System.Drawing.Color.(Purple Turquoise Orange)
∆sharpplot.SetAxisStyle System.Drawing.Color.White Causeway.LineStyle.Solid 1.2
∆sharpplot.SetFillStyles⊂,Causeway.FillStyle.Opacity78
∆sharpplot.SetFootnoteFont'Arial' 8 System.Drawing.FontStyle.Regular System.Drawing.Color.White
∆sharpplot.FootnoteStyle←Causeway.FootnoteStyles.RuledAbove
∆sharpplot.Footnote←'Data is an [X;Y] matrix of Z altitudes.'
∆sharpplot.SetHeadingFont'Times New Roman' 16 System.Drawing.FontStyle.Regular System.Drawing.Color.White
∆sharpplot.Heading←'3D Response Surface'
∆sharpplot.SetLabelFont'Times New Roman' 8 System.Drawing.FontStyle.Regular System.Drawing.Color.White
∆sharpplot.SetMargins 50 30 30 ¯50
∆sharpplot.ResponsePlotStyle←Causeway.ResponsePlotStyles.(NoLines+AltitudeShading+ScaleBar)
∆sharpplot.SetSubheadingFont'Times New Roman' 12 System.Drawing.FontStyle.Regular System.Drawing.Color.White
∆sharpplot.Subheading←'a response plot with altitude shading and perspective'
∆sharpplot.XAxisStyle←Causeway.XAxisStyles.(GridLines+AngledLabels)
∆sharpplot.YAxisStyle←Causeway.YAxisStyles.(GridLines+AngledLabels)
∆sharpplot.ZAxisStyle←Causeway.ZAxisStyles.GridLines
∆sharpplot.DrawResponsePlot((⍳100)×↓|1○(0.002×⍳100)∘.×⍳100)⍬ ⍬
∆sharpplot.SaveSvg⊂'/tmp/surface.svg'
User avatar
Adam|Dyalog
 
Posts: 134
Joined: Thu Jun 25, 2015 1:13 pm

Re: 3D graphics

Postby Stu on Sat Apr 14, 2018 2:56 am

I need some help with this. I tried running the shorter code segment at the top of your post but I got FILE NAME ERROR on file "/tmp/surface.svg". I'm running on Windows but that looks like a Linux/Unix pathname.

⎕USING←',system.dll' ',system.drawing.dll' ',sharpplot.dll'
→0/⍨⎕NC'Causeway' ⋄ (System.Drawing←System←Causeway←⎕NS ⍬).⎕CY'sharpplot.dws'
∆sharpplot←⎕NEW Causeway.SharpPlot
∆sharpplot.DrawResponsePlot((⍳100)×↓|1○(0.002×⍳100)∘.×⍳100)⍬ ⍬
∆sharpplot.SaveSvg⊂'/tmp/surface.svg'

Thanks for your help.
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: 3D graphics

Postby Adam|Dyalog on Sat Apr 14, 2018 8:49 pm

Windows generally accepts / in place of \ except for certain things on the command line.

I suspect you just don't have a folder called C:\tmp.

Now that I know that you are on Windows, try also:

      ]chart (⍳100)×↓|1○(0.002×⍳100)∘.×⍳100
User avatar
Adam|Dyalog
 
Posts: 134
Joined: Thu Jun 25, 2015 1:13 pm

Re: 3D graphics

Postby Stu on Sun Apr 15, 2018 2:25 am

Very interesting! This definitely looks like something I can work with. Thanks.
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am


Return to New to Dyalog?

Who is online

Users browsing this forum: No registered users and 1 guest