Re: two y-axis

• To: mathgroup at smc.vnet.net
• Subject: [mg27307] Re: [mg27288] two y-axis
• From: bernd at bio.vu.nl (Bernd Brandt)
• Date: Tue, 20 Feb 2001 03:05:16 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```I would like to thank everyone for the help on plotting 2 functions on
different y-axes.
Especially, Bob Hanlon for providing the function to automatically do this.

The function works excellently.

Thanks!

Bernd

> This revision uses a different scaling mechanism to handle a broader class of
> problems
>
> plotTwo[{leftAxisPlot_, rightAxisPlot_}, iter_, opts___]:=
>     Module[{pltL, pltR, ytckL, ytckR, maxL, minL, maxR, minR, f},
>       pltL = Plot[leftAxisPlot, iter, opts, DisplayFunction -> Identity];
>       pltR = Plot[rightAxisPlot, iter, opts, DisplayFunction -> Identity];
>       ytckL = (Ticks /. AbsoluteOptions[pltL])[[2]];
>       ytckR = (Ticks /. AbsoluteOptions[pltR])[[2]];
>       maxL = Max[Transpose[ytckL][[1]]]; minL = Min[Transpose[ytckL][[1]]];
>       maxR = Max[Transpose[ytckR][[1]]]; minR = Min[Transpose[ytckR][[1]]];
>       f[y_] := (y-minR)*(maxL-minL)/(maxR-minR) + minL;
>       Plot[{leftAxisPlot, f[rightAxisPlot]}, iter,
>         Evaluate[
>           Flatten[{Frame -> True, Axes -> False,
>               FrameTicks -> {Automatic, Automatic, Automatic,
>                   ytckR /. {(y__)?NumericQ, z__} :> {f[y], z}},
>               opts}]]]];
>
> red = RGBColor[1, 0, 0];  blue = RGBColor[0, 0, 1];
>
> The scaling mechanism was modified to handle plots with different offsets
> such as
>
> plotTwo[{5+Sin[x], 5*Cos[x]}, {x, 0, 2Pi}, PlotStyle -> {blue,red},
>     ImageSize -> {500,325}];
>
> Bob Hanlon
>

```

• Prev by Date: Re: ParallelMap inefficient?
• Next by Date: Hypocycloid Area
• Previous by thread: Re: two y-axis
• Next by thread: Running Mathematica 4.1 directly from CD