Re: Alternate plot scales [message #14005 is a reply to message #13888] |
Mon, 11 January 1999 00:00   |
Kevin P. Reardon
Messages: 2 Registered: January 1999
|
Junior Member |
|
|
> Brad Grom wrote:
> I'm looking for a way to draw a secondary plot scale. The problem
> is that I want the second axis scale to be a function of the
> first.
>
> For example, the lower x-axis is a standard linear scale, and the
> upper x-axis is the square of the lower axis. Now the tricky
> part: I want the tickmarks for the second axis to occur at
> regular -numeric- (not graphical) intervals.
Brad,
just playing around I came up with something like this that seems to be
at least in the general direction of what you were looking for. It ain't
pretty (in particular, the rounding of step is pretty ad hoc), but it
should at least give you some ideas on how to get what you want.
; create an X axis that runs from 50 to 10000
xaxis=(findgen(101)*99.5)+50
; plot data with no X axes
plot_oi,xaxis,findgen(100)+randomn(100,100)*1,$
xran=[max(xaxis),min(xaxis)],xsty=5,/ysty,ymargin=[10,2]
; choose a spacing (20 steps) and plot lower X axis
step=fix(((10^!x.crange(1)-10^!x.crange(0))/20.)/10.-0.5)*10
axis,xaxis=0,/xlog,xtickv=findgen(21)*step+10000,xticks=20
; choose a spacing (30 steps)
step=fix((((10^!x.crange(1))^2-(10^!x.crange(0))^2)/30.) $
/1000.-0.5)*1000.
; plot upper X axis, the square-root of the lower X-axis
axis,xaxis=1,xrange=(10^!x.crange)^2,/xlog,$
xtickv=findgen(31)*step+(10^!x.crange(0))^2,xticks=30
; plot detached X axis with normal logarithmic spacing
axis,1,-15,xaxis=0,xrange=[1/(10^!x.crange(1)),$
1/(10^!x.crange(0))],/xlog
; plot vertical lines
topticks=findgen(31)*step+(10^!x.crange(0))^2
for i=0,30 do plots,(sqrt([topticks(i),topticks(i)])),!y.crange
One could also use the XTICK_GET keyword to get the values for
each tickmarks, and then a similar FOR loop for the vertical lines.
I hope this helps a bit.
cheers,
kevin reardon
Osservatorio Astronomico di Capodimonte
|
|
|