making simple plots and graphs

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

Re: making simple plots and graphs

Postby MBaas on Mon Jun 06, 2016 3:15 pm

Thanks, that makes it much clearer now! :-)

Unfortunately, the only solution I'd know for that would be "Ktype" from RainPro - and that is not supported with SharpPlot, so I'm at the end of my rope. Hopefully someone else can jump in...!

BTW, I've edited your fn just a little bit to make it a bit more compact etc:
Code: Select all
 stu;⎕IO;n;h;v;mat
 v←(32?32)÷32 ⍝ Fake data for testing
 h←(32?32)÷32 ⍝ Fake data for testing
 ⎕IO←1
⍝ diff←(⍴v)-⍴h
⍝ :If diff=0 ⍝ v and h are of the same length
⍝     n←⍴v
⍝ :ElseIf diff>0 ⍝ v is longer
⍝     n←⍴v
⍝     h←n↑h
⍝ :Else ⍝ h is longer
⍝     n←⍴h
⍝     v←n↑v
⍝ :EndIf
n←⍴v ⋄  diff←n-⍴h
 :If n>⍴h
     h←n↑h
 :Elseif n<⍴h ⍝ h is longer
     n←⍴h
     v←n↑v
 :EndIf

 mat←(⍳n)⍪v,[0.5]h
 ch.DefineFont'GA' 'Garamond'
 ch.New 0 0 432 300
 ch.Set'DStyle' 'Rows'
 ch.Set('style' 'XYPLOT,BOXED,NOMARK,SURFACE,GRID')('Mleft' 25)('Mright' 24)('HMAR' 50 24)
 ch.Set'Ystyle' 'LEFT'
 ch.Set('Hfont' 'GABI,12')('Lfont' 'GA')
 ch.Set('XRANGE' 0(⌈/mat[1;]))('YRANGE' 0((⌈/mat[2;])⌈(⌈/mat[3;])))
 ch.Set('PATTERN' 0)
 ch.Set'HEAD' 'Correlation'
 ch.Set'KeyText' 'Vertical,Horizontal'
 ch.Set'Ktype' 'Line,Line'  ⍝ not supported
 ch.Plot mat
 PG←ch.Close
 View PG
Last edited by MBaas on Tue Jun 07, 2016 10:11 am, edited 1 time in total.
User avatar
MBaas
 
Posts: 156
Joined: Thu Oct 16, 2008 1:17 am
Location: Gründau / Germany

Re: making simple plots and graphs

Postby Stu on Mon Jun 06, 2016 4:38 pm

Thanks for compacting my function. It does look a bit more professional now!

A while back I wrote a similar function using RainPro. All the right things seemingly just happened without my having to study manuals and find sample code. This makes me wonder why Dyalog is abandoning RainPro. The Sharp Plot APL documentation (as opposed to just example code) is inadequate, and there are problems like the one you've been helping me with.
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: making simple plots and graphs

Postby Stu on Mon Jun 06, 2016 6:24 pm

Just for the sake of comparison, here's what I did in RainPro:

v matplot h;rv;rh;n;MAT;PG

⍝ Type this before using matplot:
⍝ )copy rainpro ch PostScrp

rv←⍴v
rh←⍴h
:If rh>rv
v←rh↑v
n←rh
:Else
h←rv↑h
n←rv
:EndIf
MAT←((n,1)⍴v),(n,1)⍴h
ch.Set('Style' 'Boxed,Nomark')('Head' 'Correlation')('Key' 'Vertical,Horizontal')
ch.Set('YStyle' 'ForceZero,plain')('Ytick' 2 1)
ch.Plot MAT
PG←ch.Close
PostScrp.View PG
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: making simple plots and graphs

Postby Nicolas|Dyalog on Tue Jun 07, 2016 12:02 pm

Hi !

SharpRain is there only as a helper to migrate old RainPro scripts to SharpPlot.

For the help samples, I apologise for all of them being in C#. Translating them all is not a small task. In the mean time, the SharpPlot help has an entry about that : Getting Started -> SharpPlot in different languages.
http://sharpplot.com/Languages.htm
It shows a typical script (all API usages) in different languages, as a rosetta stone to convert samples.
If you have trouble converting SharpPlot samples into APL, please contact me, and I'll add it to the help.

Cheers,

Nic.
Nicolas|Dyalog
 
Posts: 17
Joined: Wed Sep 10, 2008 9:39 am

Re: making simple plots and graphs

Postby Vince|Dyalog on Tue Jun 07, 2016 12:34 pm

Hi Stu,

This is what Nic has written in the past about why we are recommending the move to SharpPlot:

SharpPlot has been around for about ten years, as a C#-compiled refactored version of RainPro, and is its definite replacement.

Advantages of SharpPlot:
- More consistent API, and clearer documentation
- Nicer graphics (alpha blending, anti-aliased raster graphics)
- Better performance (SharpPlot is consistently several times faster than RainPro)
- Multi-platform (RainPro was supported only on windows)

Regards,

Vince
Vince|Dyalog
 
Posts: 413
Joined: Wed Oct 01, 2008 9:39 am

Re: making simple plots and graphs

Postby Stu on Tue Jun 07, 2016 3:34 pm

The SharpPlot graphics are definitely a lot nicer than RainPro's, but the RainPro version of my little plotting function runs quite a bit faster (because it's not an emulation?).

Full documentation of the APL implementation of Sharp Plot is indispensable; otherwise, you have to peruse the Samples and/or use the "Rosetta Stone" example to infer the correct syntax, a tedious and error-prone process.

Thanks to everyone who responded to my questions.
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: making simple plots and graphs

Postby Nicolas|Dyalog on Thu Jun 09, 2016 2:21 pm

Hi Stu.

I'm positive that the SharpPlot .Net assembly is consistently about an order of magnitude faster than RainPro.

Michael Baas has nicely pointed you at SharpRain - but the best way to use it it not just to run the rainpro script in "emulation mode", but convert them to pure-SharpPlot script, which will end up faster than you original rainpro script.

Please contact me directly (nicolas@dyalog.com) so that I can help you convert your RainPro scripts.

Cheers,

Nic.
Nicolas|Dyalog
 
Posts: 17
Joined: Wed Sep 10, 2008 9:39 am

Previous

Return to New to Dyalog?

Who is online

Users browsing this forum: No registered users and 1 guest