making simple plots and graphs
27 posts
• Page 2 of 3 • 1, 2, 3
Re: making simple plots and graphs
Sorry for misleading you, this is more painful that it should be ;-)
Let's focus on getting on sample for a nice linechart:
Have a look at the code...and then replace last line with this:
and then you should be able to execute
Let's focus on getting on sample for a nice linechart:
- Code: Select all
)load sharprain
)cs Samples
)ed Iceland
Have a look at the code...and then replace last line with this:
- Code: Select all
PG←#.ch.Close ⋄ r←'#.Samples.PG View ''''⍝ for the Glacier data'
and then you should be able to execute
- Code: Select all
Iceland
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: making simple plots and graphs
We're getting closer! I can now see lots of coded examples. This is good. However, I have encountered some problems. When I modify "Iceland" as you say, I get this:
*** ERROR *** Style : Unsupported : XS ZANG
*** ERROR *** Style : Unsupported : XS ZANG
#.Samples.PG View'' ⍝ for the Glacier data
I also tried "Multiple", "Timeseries", and "Sample". With these I get:
VALUE ERROR
View[2] r←#.PostScrp.View arg
*** ERROR *** Style : Unsupported : XS ZANG
*** ERROR *** Style : Unsupported : XS ZANG
#.Samples.PG View'' ⍝ for the Glacier data
I also tried "Multiple", "Timeseries", and "Sample". With these I get:
VALUE ERROR
View[2] r←#.PostScrp.View arg
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: making simple plots and graphs
Not at the PC atm, so I can't check, but I guess that the 3 failing fns will need that same last-line-fix as before.
The error-msgs indicate that certain features (mentioned in the msg) are not available, but the graph might still be useable...
The error-msgs indicate that certain features (mentioned in the msg) are not available, but the graph might still be useable...
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: making simple plots and graphs
It appears that the final line of each of the Samples must be:
R←'#.View #.Samples.PG'
Then you assign the value of, e.g., Timeseries, to some variable, say R:
R←Timeseries
R will then contain
#.View #.Samples.PG
which you then execute from the command line (or with ⍎?) to display the graph.
Is this more or less how the examples in sharprain are supposed to work?
R←'#.View #.Samples.PG'
Then you assign the value of, e.g., Timeseries, to some variable, say R:
R←Timeseries
R will then contain
#.View #.Samples.PG
which you then execute from the command line (or with ⍎?) to display the graph.
Is this more or less how the examples in sharprain are supposed to work?
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: making simple plots and graphs
Hmmm, was'n it #.Samples.PG View'' that we changed to in thebIcekand-example?
In general,, the examples never output directly but just return the viewable code. In your own fn, there's no need to follow that style, instead of outputting that..View..-stuff, you can do it right away (no quotes, no excute).
In general,, the examples never output directly but just return the viewable code. In your own fn, there's no need to follow that style, instead of outputting that..View..-stuff, you can do it right away (no quotes, no excute).
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: making simple plots and graphs
The last line in all of the examples has to be: #.View #.Samples.PG. If, instead, you just write View #.Samples, you get this error message:
VALUE ERROR
View[2] r←#.PostScrp.View arg
Some of the other examples in Samples generate other error messages that I currently don't understand.
VALUE ERROR
View[2] r←#.PostScrp.View arg
Some of the other examples in Samples generate other error messages that I currently don't understand.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: making simple plots and graphs
Thanks for taking the time to help me out with this problem. I think I've now got the hang of using the Sharp Plot Samples. I hadn't worked with namespaces before and that was hindering me from understanding of what was going on. The chapter on namespaces in "Mastering Dyalog" was very helpful.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: making simple plots and graphs
I need one last bit of help to get my simple plotting function going. Most of it works fine: the two vectors, "Vertical" and "Horizontal," are nicely plotted with solid and dashed lines, respectively, the heading is centered at the top, and the X and Y tick marks are correct. The only problem is that the keys are small empty boxes instead of short solid or dashed line segments. I've looked at all the examples in Samples, but I can't figure out how a key gets associated with the corresponding line on the plot. Here are the last few lines of my function:
ch.Plot mat ⍝ 3×n matrix: one row of X-ordinates plus two rows of data
ch.SetKeyText'Vertical,Horizontal'
PG←ch.Close
View PG
To get as far as I have, I've had to so something I really dislike: writing "experimental" programs to see what the interpreter/compiler does. The Sharp Plot documentation, which appears to be written for an experienced C++ programmer isn't much help.
ch.Plot mat ⍝ 3×n matrix: one row of X-ordinates plus two rows of data
ch.SetKeyText'Vertical,Horizontal'
PG←ch.Close
View PG
To get as far as I have, I've had to so something I really dislike: writing "experimental" programs to see what the interpreter/compiler does. The Sharp Plot documentation, which appears to be written for an experienced C++ programmer isn't much help.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: making simple plots and graphs
I'm not sure I understand exactly what you're after - does the Keystyle-property help? If not, would it be possible to post a complete example, so it's easier to repro and fix?
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: making simple plots and graphs
Yes, of course, I should have sent the whole thing. Here it is:
plott;⎕IO
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
mat←(3,n)⍴0
mat[1;]←⍳n
mat[2;]←v
mat[3;]←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.SetKeyText'Vertical,Horizontal'
ch.Plot mat
PG←ch.Close
View PG
plott;⎕IO
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
mat←(3,n)⍴0
mat[1;]←⍳n
mat[2;]←v
mat[3;]←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.SetKeyText'Vertical,Horizontal'
ch.Plot mat
PG←ch.Close
View PG
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
27 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group