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.")
|
|
|