MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Multiple Axes

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17013] Re: [mg16944] Multiple Axes
  • From: BobHanlon at aol.com
  • Date: Sat, 10 Apr 1999 02:13:41 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

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.
>

Jan,

Needs["Statistics`ContinuousDistributions`"];
mu = 2.; sigma = 4.;
dist = NormalDistribution[mu, sigma];

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

(* plot removed *)

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

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

10

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-3sigma,"\[Mu]-3\[Sigma]"}, 
		{mu-2sigma,"\[Mu]-2\[Sigma]"}, {mu-sigma,"\[Mu]-\[Sigma]"}, 
		{mu,"\[Mu]"}, {mu+sigma,"\[Mu]+\[Sigma]"},
		{mu+2sigma,"\[Mu]+2\[Sigma]"},{mu+3sigma,"\[Mu]+3\[Sigma]"}}, 
		Table[{mu+k*sigma, ""}, {k, -2.5, 2.5}]];

Plot[{scale*PDF[dist, x], CDF[dist, x]}, 
	{x, mu-3.1sigma, mu+3.1sigma}, 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}];

(* plot removed *)


Bob Hanlon


  • Prev by Date: RE: Plot
  • Next by Date: Re: PoissonDistribution
  • Previous by thread: Multiple Axes
  • Next by thread: Comparison of Mathematica on Various Computers