|
|
Re: second Y axis. [message #86978 is a reply to message #86943] |
Wed, 18 December 2013 12:07   |
limiqt
Messages: 27 Registered: October 2013
|
Junior Member |
|
|
On Monday, December 16, 2013 8:59:39 AM UTC-5, David Fanning wrote:
> Lim writes:
>
>
>
>> I was wondering if someone has a suggestion to produce a second Y axis, using the coyote graphic libraries, similar to the figure at: http://www2.astro.psu.edu/xray/docs/TARA/ae_users_guide/img1 05.png
>
>>
>
>> The second Y axis looks like is floating in the graph.
>
>>
>
>> I will appreciate any suggestions.
>
>
>
> Have you checked the Coyote Plot Gallery? Almost guaranteed to find what
>
> you are looking for there. :-)
>
>
>
> http://www.idlcoyote.com/gallery/index.html
>
>
>
> 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.")
Hi David, There is a tiny diference between your example at http://www.idlcoyote.com/gallery/additional_axes_plot.pro and the figure I mentioned: the second Y axis in your example follows the length of the primary Y axis. In the example I mentioned the second Y axis on the right looks like it is independent of the Y axis on the left. Probably I am missing something.
Thanks
Lim
|
|
|
Re: second Y axis. [message #86983 is a reply to message #86941] |
Wed, 18 December 2013 16:07   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Lim writes:
> I was wondering if someone has a suggestion to produce a second Y axis, using the coyote graphic libraries, similar to the figure at: http://www2.astro.psu.edu/xray/docs/TARA/ae_users_guide/img1 05.png
>
> The second Y axis looks like is floating in the graph.
>
> I will appreciate any suggestions.
Ah, I see. Well, this is one place where object graphics probably has an
advantage over direct graphics. I think you are going to have to do
something like this. Here is modified code from what you can find on my
web page:
PRO Additional_Axes_Plot
; Create some data.
data_1 = cgScaleVector(cgDemodata(17), 0.0, 1.0)
data_2 = cgScaleVector(cgDemodata(17), 0.0, 1000.0)
data_3 = (Findgen(101)+1) / 5
thick = (!D.Name EQ 'PS') ? 4 : 2
; Open a window and draw the plot without either of the Y axes.
cgDisplay, 600, 450
cgPlot, data_1, YStyle=4, Position=[0.15, 0.15, 0.7, 0.820], /NoData
; Draw the first Y axis in red.
cgAxis, YAxis=0.0, /Save, Color='red7', YTitle='Data 1'
cgOPlot, data_1, Color='red7', Thick=thick
; Draw the second Y axis in green.
cgAxis, YAxis=1.0, /Save, Color='grn7', YTitle='Data 2', $
YRange=[0,1000]
cgOPlot, data_2, Color='grn7', LineStyle=2, Thick=thick
; Draw the third Y axis in blue.
thisWindow = !D.Window
cgDisplay, !D.X_Size, !D.Y_Size, /Free
cgPlot, data_1, YStyle=4, Position=[0.15, 0.15, 0.7, 0.650], /NoData
WDelete, !D.Window
WSet, thisWindow
cgAxis, 0.85, 0.15, /Normal, YAxis=1.0, /Save, Color='blu7', $
YTitle='Data 3', YRange=[0.1,100], /YLog
cgOPlot, data_3, Color='blu7', LineStyle=1, Thick=thick
END ;*********************************************************** ******
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: second Y axis. [message #86995 is a reply to message #86983] |
Thu, 19 December 2013 06:18   |
limiqt
Messages: 27 Registered: October 2013
|
Junior Member |
|
|
On Wednesday, December 18, 2013 7:07:14 PM UTC-5, David Fanning wrote:
> Lim writes:
>
>
>
>> I was wondering if someone has a suggestion to produce a second Y axis, using the coyote graphic libraries, similar to the figure at: http://www2.astro.psu.edu/xray/docs/TARA/ae_users_guide/img1 05.png
>
>>
>
>> The second Y axis looks like is floating in the graph.
>
>>
>
>> I will appreciate any suggestions.
>
>
>
> Ah, I see. Well, this is one place where object graphics probably has an
>
> advantage over direct graphics. I think you are going to have to do
>
> something like this. Here is modified code from what you can find on my
>
> web page:
>
>
>
> PRO Additional_Axes_Plot
>
>
>
> ; Create some data.
>
> data_1 = cgScaleVector(cgDemodata(17), 0.0, 1.0)
>
> data_2 = cgScaleVector(cgDemodata(17), 0.0, 1000.0)
>
> data_3 = (Findgen(101)+1) / 5
>
>
>
> thick = (!D.Name EQ 'PS') ? 4 : 2
>
>
>
> ; Open a window and draw the plot without either of the Y axes.
>
> cgDisplay, 600, 450
>
> cgPlot, data_1, YStyle=4, Position=[0.15, 0.15, 0.7, 0.820], /NoData
>
>
>
> ; Draw the first Y axis in red.
>
> cgAxis, YAxis=0.0, /Save, Color='red7', YTitle='Data 1'
>
> cgOPlot, data_1, Color='red7', Thick=thick
>
>
>
> ; Draw the second Y axis in green.
>
> cgAxis, YAxis=1.0, /Save, Color='grn7', YTitle='Data 2', $
>
> YRange=[0,1000]
>
> cgOPlot, data_2, Color='grn7', LineStyle=2, Thick=thick
>
>
>
> ; Draw the third Y axis in blue.
>
> thisWindow = !D.Window
>
> cgDisplay, !D.X_Size, !D.Y_Size, /Free
>
> cgPlot, data_1, YStyle=4, Position=[0.15, 0.15, 0.7, 0.650], /NoData
>
> WDelete, !D.Window
>
> WSet, thisWindow
>
>
>
> cgAxis, 0.85, 0.15, /Normal, YAxis=1.0, /Save, Color='blu7', $
>
> YTitle='Data 3', YRange=[0.1,100], /YLog
>
> cgOPlot, data_3, Color='blu7', LineStyle=1, Thick=thick
>
>
>
>
>
> END ;*********************************************************** ******
>
>
>
> 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.")
Hi David, yes, your solution is very cool. thank you so much.
|
|
|
Re: second Y axis. [message #86998 is a reply to message #86995] |
Thu, 19 December 2013 06:32   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Lim writes:
> Hi David, yes, your solution is very cool. thank you so much.
Well, I woke up in the middle of the night with a more elegant solution
based in my cgCoord object. It *should* be possible to replace all the
pixmap stuff with this:
coord = cgCoord(Position=[0.15, 0.15, 0.7, 0.650])
coord -> Draw
The Draw method of the object does *exactly* what the whole pixmap thing
is doing. Except that it doesn't work! I really don't know why. I've
fooled with it some this morning, but I'm no closer to understanding it.
Everything I "test" in the environment is exactly the same, but for some
reason the overplot doesn't recognize that it is overplotting onto a log
axis, even though the axis is drawn as a log axis in the right place.
I have a full day, so I don't know if I'll be able to get back to it
anytime soon. This is the kind of thing that drives me crazy, though.
:-)
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: second Y axis. [message #87000 is a reply to message #86998] |
Thu, 19 December 2013 06:59  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
>
> Lim writes:
>
>> Hi David, yes, your solution is very cool. thank you so much.
>
> Well, I woke up in the middle of the night with a more elegant solution
> based in my cgCoord object. It *should* be possible to replace all the
> pixmap stuff with this:
>
> coord = cgCoord(Position=[0.15, 0.15, 0.7, 0.650])
> coord -> Draw
>
> The Draw method of the object does *exactly* what the whole pixmap thing
> is doing. Except that it doesn't work! I really don't know why. I've
> fooled with it some this morning, but I'm no closer to understanding it.
> Everything I "test" in the environment is exactly the same, but for some
> reason the overplot doesn't recognize that it is overplotting onto a log
> axis, even though the axis is drawn as a log axis in the right place.
>
> I have a full day, so I don't know if I'll be able to get back to it
> anytime soon. This is the kind of thing that drives me crazy, though.
> :-)
OK, it drove me crazy enough, I thought I would just figure it out. :-)
So, I replaced this:
thisWindow = !D.Window
cgDisplay, !D.X_Size, !D.Y_Size, /Free
cgPlot, data_1, YStyle=4, Position=[0.15, 0.15, 0.7, 0.650], /NoData
WDelete, !D.Window
WSet, thisWindow
With this (initially):
coord = cgCoord(Position=[0.15, 0.15, 0.7, 0.650]
coord.draw
The axis is drawn in the right place, but the plot is wrong.
What is happening is that the default ranges are 0 to 1. So that when I
overdraw the plot onto the coordinates I set up, I am only seeing that
part of the plot from 0 to 1 in X, instead of from 0 to 100. What I
should have done is set up the coordinate object like this:
coord = cgCoord(Position=[0.15, 0.15, 0.7, 0.650], XRange=[0,100])
coord.draw
This works correctly, as I expected. :-)
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.")
|
|
|