       Re: Combining Plots with Different Ordinate Axes in Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg95229] Re: Combining Plots with Different Ordinate Axes in Mathematica
• From: Andreas <aagas at ix.netcom.com>
• Date: Sun, 11 Jan 2009 06:38:57 -0500 (EST)

```I came across a solution a long time ago, that I believe someone posted on the Mathematica Student forum.  What I have follows, if anyone can provide the original reference, I'd appreciate it.

____________

In a message dated 4/8/99 10:54:07 AM,je224 at cam.ac.uk writes:

Is there a way of making Mathematica include multiple x-or y-axes?  It seems that when one combines several graphs,the axes are always adjusted accordingly.

Remove["Global`*"]
<< Statistics`ContinuousDistributions`
mu = 2.; sigma = 4.;
dist = NormalDistribution[mu, sigma]

Plot[{PDF[dist, x], CDF[dist, x]}, {x, mu - 3 sigma, mu + 3 sigma}];

To put the plots on the same size scale,the PDF values will be scaled by

scale = Round[CDF[dist, mu + 3 sigma]/PDF[dist, mu]]

and the second y-axis will have its Ticks labeled accordingly.Simultaneously,the second y-axis will be scaled in standard deviations about the mean.

red = RGBColor[1, 0, 0];
blue = RGBColor[0, 0, 1];
pdfTicks =
Join[Table[{y, StyleForm[y/scale, FontColor -> red]}, {y, 0, 1,
0.2}], minorTicks = Table[{y, ""}, {y, 0.1, 0.9, 0.2}]];

cdfTicks =
Join[Table[{y, StyleForm[y, FontColor -> blue]}, {y, 0, 1, 0.2}],
minorTicks];

sigmaTicks =
Join[{{mu - 3 sigma, "\[Mu]-3\[Sigma]"}, {mu - 2 sigma,
"\[Mu]-2\[Sigma]"}, {mu - sigma, "\[Mu]-\[Sigma]"}, {mu,
"\[Mu]"}, {mu + sigma, "\[Mu]+\[Sigma]"}, {mu + 2 sigma,
"\[Mu]+2\[Sigma]"}, {mu + 3 sigma, "\[Mu]+3\[Sigma]"}},
Table[{mu + k*sigma, ""}, {k, -2.5, 2.5}]];

Plot[{scale*PDF[dist, x], CDF[dist, x]}, {x, mu - 3.1 sigma,
mu + 3.1 sigma}, ImageSize -> {420, 260}, PlotStyle -> {red, blue},
Axes -> False, Frame -> True,
PlotLabel ->
StyleForm["Normal Distribution\n", FontWeight -> "Bold",
FontSize -> 12], FrameLabel -> {"x", "PDF\n", None, "CDF"},
FrameTicks -> {Automatic, pdfTicks, sigmaTicks, cdfTicks}];

____________________

This code comes from a very early version but the Automated Compatibility Tool should give you something workable.  Good luck.

```

• Prev by Date: Re: Plot in Background of Manipulate
• Next by Date: Re: Solve / NSolve
• Previous by thread: Re: Combining Plots with Different Ordinate Axes in Mathematica
• Next by thread: Re: Fourier[TriangleWave]