comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » multi scatter plots, layout issues
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
multi scatter plots, layout issues [message #90784] Wed, 15 April 2015 12:03 Go to next message
Matteo is currently offline  Matteo
Messages: 28
Registered: August 2011
Junior Member
Hi,

I'm interested in using CGSCATTER2D to produce multiple plots (3x2) in a single page. Not limited to CGSCATTER2D, I still find it difficult to control the positioning of multi plots and the size of their titles, specifically when I want to save to ps. For example the following instructions do not lead to the desired effect. Here I'm replotting the same plot 6 times, but the plots don't have an Aspect Ratio of 1, which I believe is mentioned in the documentation for CGSCATTER2D, adn the resulting xgap is way too big:


----------------
data_1 = cgDemoData(1)+ RandomU(seed, 101) * 10
data_2 = cgDemoData(1)+ RandomU(seed, 101) * 20 + 50

cgWindow, WXSize=900, WYSize=1200
positions = cgLayout([2,3], OXMargin=[0,0], OYMargin=[2,2], XGap=0, YGap=2, Aspect=1.0)

FOR j=0,5 DO BEGIN
p=positions[*,j]
cgScatter2D, data_1, data_2, position=p, XTitle='Study Time (minutes)', NoErase=j NE 0, charsize=0.5, PSym=16, FThick=2, /Add
ENDFOR
-----------------

I know the CG routines are built to be device independent, so can anybody tell me what's the most straightforward way to obtain something as nice as the ?
Should I give up CGLAYOUT and simply resort to P.MULTI? I would like the final result to look evenly distributed, say as in: http://www.idlcoyote.com/gallery/small_multiple_contour_plot .png or http://www.idlcoyote.com/gallery/histogram_plot.png.

Thanks,
matteo
Re: multi scatter plots, layout issues [message #90786 is a reply to message #90784] Wed, 15 April 2015 12:26 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
On Wednesday, April 15, 2015 at 2:03:35 PM UTC-5, Matteo wrote:
>
> I know the CG routines are built to be device independent, so can anybody tell me what's the most straightforward way to obtain something as nice as the ?
> Should I give up CGLAYOUT and simply resort to P.MULTI? I would like the final result to look evenly distributed, say as in: http://www.idlcoyote.com/gallery/small_multiple_contour_plot .png or http://www.idlcoyote.com/gallery/histogram_plot.png.
>
> Thanks,
> matteo

I don't typically use cgWindow unless the plots are relatively simple. A small modification to your program gives what I think is what you're after.

Basically, I replace with cgWindow with cgPS_Open, comment out the /Add, and add a cgPS_Close at the end. I also prefer Encapsulated PS files, since the bounding box is included.

data_1 = cgDemoData(1)+ RandomU(seed, 101) * 10
data_2 = cgDemoData(1)+ RandomU(seed, 101) * 20 + 50

;cgWindow, WXSize=900, WYSize=1200
cgPS_Open, file='test.eps', xs=4.5, ys=6, /inches, /nomatch, /encap
positions = cgLayout([2,3], OXMargin=[0,0], OYMargin=[2,2], XGap=0, YGap=2, Aspect=1.0)

FOR j=0,5 DO BEGIN
p=positions[*,j]
cgScatter2D, data_1, data_2, position=p, XTitle='Study Time (minutes)', NoErase=j NE 0, charsize=0.5, PSym=16, FThick=2;, /Add
ENDFOR

cgPS_Close

END
Re: multi scatter plots, layout issues [message #90787 is a reply to message #90784] Wed, 15 April 2015 12:50 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matteo writes:

> I'm interested in using CGSCATTER2D to produce multiple plots (3x2) in a single page. Not limited to CGSCATTER2D, I still find it difficult to control the positioning of multi plots and the size of their titles, specifically when I want to save to ps. For example the following instructions do not lead to the desired effect. Here I'm replotting the same plot 6 times, but the plots don't have an Aspect Ratio of 1, which I believe is mentioned in the documentation for
CGSCATTER2D, adn the resulting xgap is way too big:
>
>
> ----------------
> data_1 = cgDemoData(1)+ RandomU(seed, 101) * 10
> data_2 = cgDemoData(1)+ RandomU(seed, 101) * 20 + 50
>
> cgWindow, WXSize=900, WYSize=1200
> positions = cgLayout([2,3], OXMargin=[0,0], OYMargin=[2,2], XGap=0, YGap=2, Aspect=1.0)
>
> FOR j=0,5 DO BEGIN
> p=positions[*,j]
> cgScatter2D, data_1, data_2, position=p, XTitle='Study Time (minutes)', NoErase=j NE 0, charsize=0.5, PSym=16, FThick=2, /Add
> ENDFOR
> -----------------
>
> I know the CG routines are built to be device independent, so can anybody tell me what's the most straightforward way to obtain something as nice as the ?
> Should I give up CGLAYOUT and simply resort to P.MULTI? I would like the final result to look evenly distributed, say as in: http://www.idlcoyote.com/gallery/small_multiple_contour_plot .png or http://www.idlcoyote.com/gallery/histogram_plot.png.

For some reason I don't understand, when you try to put the scatter
plots into a resizeable window, the window sizes are not being reported
correctly. I'll have to look into this. But, I wouldn't be doing this in
a resizeable window, I don't think. I would try to do this in a regular
window like this:

Pro ScatterExample
data_1 = cgDemoData(1)+ RandomU(seed, 101) * 10
data_2 = cgDemoData(1)+ RandomU(seed, 101) * 20 + 50

cgDisplay, 900, 1200
positions = cgLayout([2,3], OXMargin=[0,0], OYMargin=[2,2], $
XGap=0, YGap=2, Aspect=1.0)

FOR j=0,5 DO BEGIN
p=positions[*,j]
cgScatter2D, data_1, data_2, position=p, $
XTitle='Study Time (minutes)', NoErase=j NE 0, $
charsize=0.5, PSym=16, FThick=2
ENDFOR
END


Then, if I wanted to display this in PostScript, I would do something
like this:

cgPS_Open, 'scatterexample.ps'
ScatterExample
cgPS_Close, /PNG

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: multi scatter plots, layout issues [message #90788 is a reply to message #90787] Wed, 15 April 2015 13:18 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> For some reason I don't understand, when you try to put the scatter
> plots into a resizeable window, the window sizes are not being reported
> correctly. I'll have to look into this

OK, it appears cgLayout will not work with a resizeable Coyote Graphics
window at the moment. The reason is complicated, but it has to do with
the fact that users can't draw directly into a resizeable graphics
window. The window actually "hides" its identity so the user can't do
this accidentally. You have to "add" a command to the window.

At the time the command is "executed", the window reveals its identity
and allows you to draw into it. Since cgLayout has not been added to the
window (it can't be), it has no access to the window information in the
resizeable graphics window to calculate positions correctly.

Since it has no access (it sees the current window index number as -1),
it used the default window size to calculate the plot positions. This,
obviously, will be wrong in this case, since the default position is
640x512 and the window you want is 900x1200. This is why you are not
getting what you expect.

It is possible I might yet discover a way to give cgLayout access to a
hidden cgWindow, but I have other things to do today and can no longer
work on this. The workaround, of course, is to simply use a regular
IDL window (cgDisplay). This will give you device independence, since
cgDisplay works the "same" in PostScript.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: multi scatter plots, layout issues [message #90791 is a reply to message #90784] Wed, 15 April 2015 21:03 Go to previous message
Matteo is currently offline  Matteo
Messages: 28
Registered: August 2011
Junior Member
Thank you Phillip and Dave! Glad to see it wasn't something too trivial that I had missed about cgLayout.

m
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FG-arithmetic error and moving objects
Next Topic: cgdisplay

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 07:23:59 PDT 2025

Total time taken to generate the page: 0.00593 seconds