COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### ListPlot with two horizontal axes

• Follow

```I have data I would like to plot with two horizontal axes.  I.e.
signal magnitude as a function of wavelength and frequency.  Is there
a way to label the horizontal axis with two scales? (Note, freq is
inversely proportional to wavelength.)
Thanks!
Eli.

```
 0

```You could use a Frame plot (Frame -> True) instead of an Axes plot and then
use the FrameTicks option to specify special ticks for the top of the Frame.
This requires a bit of detailed work if you want both major and minor ticks.

You could use the Presentations package, which has a CustomTicks function
that makes it easy to specify major and minor ticks with any 1-1 mapping to
the underlying plot coordinate. Or, again with Presentations, you could
dispense with the regular labeled axes and use XTickScale and YTickScale to
construct your own free standing scales. That way you might obtain two
XTickScales that were adjacent to each other.

David Park
djmpark@comcast.net
http://home.comcast.net/~djmpark/

From: EliL [mailto:elansey@gmail.com]

I have data I would like to plot with two horizontal axes.  I.e.
signal magnitude as a function of wavelength and frequency.  Is there
a way to label the horizontal axis with two scales? (Note, freq is
inversely proportional to wavelength.)
Thanks!
Eli.

```
 0

```Hi Eli,
> I have data I would like to plot with two horizontal axes.  I.e.
> signal magnitude as a function of wavelength and frequency.  Is there
> a way to label the horizontal axis with two scales? (Note, freq is
> inversely proportional to wavelength.)
> Thanks!
> Eli.
>
One way is to use different labels on the same scales
tiktop = {#, #} & /@ Range[10];
tikbot = {#, 1/#} & /@ Range[10];
Plot[x, {x, 1, 10},
FrameTicks -> {{Automatic, Automatic}, {tiktop, tikbot}},
Frame -> True, Axes -> False
]

Another way is to manually construct the axis using a combination of
differently-oriented lines & text, and placing it using Epilog.  This
second way is very, very fiddly.

D.

```
 0

```data = Table[{x, x}, {x, 30, 300, 50}];

ListLinePlot[data,
Frame -> True,
Axes -> False,
FrameLabel -> {
{None, None},
{"Frequency in MHz",
"Wavelength in meters" }},
FrameTicks -> {
{Automatic, Automatic},
{Automatic, Join[
Flatten[
Table[{300/len, , {0.00625, 0.},
{GrayLevel[0.],
AbsoluteThickness[0.125]}},
{n, 1, 3},
{len, 2^(n - 1), 2^n, 2^(n - 4)}],
1],
Table[{300/len, len}, {len, 1, 10}]]}},
ImageSize -> 600,
PlotRange -> {{30, 300}, Automatic}]

Bob Hanlon

---- EliL <elansey@gmail.com> wrote:

=============
I have data I would like to plot with two horizontal axes.  I.e.
signal magnitude as a function of wavelength and frequency.  Is there
a way to label the horizontal axis with two scales? (Note, freq is
inversely proportional to wavelength.)
Thanks!
Eli.

```
 0

3 Replies
469 Views

Similiar Articles:

7/24/2012 12:32:01 AM