# Re: Two x axes per plot

• Subject: Re: Two x axes per plot
• From: philip aldis <teal(at)dera.gov.uk>
• Date: Thu, 05 Nov 1998 13:38:55 +0000
• Newsgroups: comp.lang.idl-pvwave
• Organization: Defence Evalation Research Agency
• References: <1998Nov4.180516.14187@news.wrc.xerox.com>
• Xref: news.doit.wisc.edu comp.lang.idl-pvwave:12666

```

> David Fanning has a nice illustration of how to use a linear and
> a log 'y' axes in the same plot. I have a question that is related
> to this, but not quite the same. How does one have an upper and
> a lower x axes, where the lower one in linear and the upper one
> has *some selected* values of a function of x.
>
> The example that comes to mind is the typical Arrhenius plot of
> y = A*exp(-T0/T), where one plots ln(y) vs 1/T to show the
> exponential nature of the data. This can be accomplished with
>
> plot_oi, 1/T, y, ....
>
> Now, how does one plot an upper 'x' axis which gives the
> corresponding values of T at "convenient" values. Say, that
>
> 100 < T < 500
>
> so that the lower axis goes from 0.002 to 0.010. The upper
> axis should have tick marks and the values at, say, 100, 200,
> 300, 400 and 500. How does one position the tick marks? Is it
> at all possible?
>
> thanks
> sj
>
> --
>

I've not actually had to do this before, but I had a little play and I
think (and hope) that this is the right way, although I'm sure of the
experts will reply later to tell you how it should be done.

First plot the graph as you have been doing, but add the keyword
xstyle=5 to your plot call - this suppresses the xaxes from being drawn.

Then you want to draw the 1/T axis. To do this enter:

AXIS, axis=0

--the xaxis=0 specifies the bottom xaxis. You can format this axis as
you like, check out the help on AXIS to find out more.

Then to draw the upper axis, which has different tick values -

AXIS, xaxis=1, xtickv=[ array], xticks= number

the xticks keyword sets the number of tick INTERVALS, (so therefore
there are number+1 tick marks), to appear on the axes, while the array
that you input for the xtickv keyword is the specific labels that it
uses for the axis. You have to make sure that the size of the array is
n+1. The AXIS procedure simply uses the array to label each tick mark
and of course you can produce the array as a function of every tenth
If you wanted to label every tenth data point out of a data set of
100, i.e 11 ticks, then xticks=11 and for xtickv do this:

a=findgen(11)*10
xtickv = function(data[a])

I hope that one, what I have said works, and two this is what you wanted

cheers,
Phil Aldis

```