axis ystyle=0 double rounding problem [message #64862] |
Wed, 21 January 2009 07:33 |
Joost Aan de Brugh
Messages: 16 Registered: July 2008
|
Junior Member |
|
|
Hello all,
I just encountered a problem I could solve because I have done quite
some work on plotting and axes. But for anyone, this could make hidden
errors that ruin a lot of work.
Suppose you want to make a plot with left and right y-axes to plot two
different properties in one graph. You do something like: (I reduce a
lot of complex things from my own work, I hope that I do not make any
trivial mistakes by doing so).
; Plot the left graph
plot,x,lefty,ystyle=8,....
! Plot the right graph
plot,x,righty,ystyle=4,/NoErase,...
! Now make the right axis
axis,yaxis=1,...
The hidden problem occurs when bit one of ystyle is not set in the
axis-command.
I encountered the problem when I had some data ranging from 0 to 1.22
for my right y-axis.
I do the plot-command (plot,x,righty,ystyle=4,/NoErase)
I did not set the 1-bit of ystyle, so the y-range will be from 0 to
1.4 (steps 0.2) and that is indeed what I want. The !y.crange will be
set to [0,1.4].
Now I do the axis-command (axis,yaxis=1) ; Note: ystyle=0
And now the problem occurs. IDL is 'plotting' from 0 to 1.4 (the !
y.crange) for the axis and autoscales again to 0 - 1.5. So my axis
goes from 0 to 1.5, while the data is plot as if the axis goes from 0
to 1.4, confusing the values.
I tackled this problem because I had to compare data sets that should
be equal (one on the left axis and one on the right). The graphs
overlapped, but one axis ranged from 0 to 1.4 and the other from 0 to
1.5. But If I would have had a different case, I could have caused a
lot of problems.
The problem is solved by always setting ystyle=1 to an axis-command.
Does anyone knows an example in which it makes sense to use this axis-
command with the 1-bit not set?
Regards,
Joost
|
|
|