MathGroup Archive 2008

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

Search the Archive

Re: Advanced plotting

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91995] Re: Advanced plotting
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 16 Sep 2008 19:24:24 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <gal3jl$e1b$1@smc.vnet.net>

kazik.lakomy at gmail.com wrote:

> I am wondering is there a possibility in Mathematica 6 to use two
> different scales on vertical axis- one scale on the left one and the
> other on the right one (with a horizontal axis being common for both
> the vertical ones). [snip]


The Technical Support FAQ titled, "Can I create a two-axis graph in 
Mathematica?" should answer your question. See,

http://support.wolfram.com/mathematica/graphics/2d/twoaxisgraph.html


Note that you must *not* load the packageGraphics`MultipleListPlot` when 
working with version 6.x. For instance,

In[1]:= $Version
TwoAxisPlot[{f_, g_}, {x_, min_, max_}, frange_,
grange_, (opts___)?OptionQ] :=
Module[{old, new, scale, pts, gstuff, fstuff}, {fm, fM} = frange;
{gm, gM} = grange;
scale[var_] = ((var - gm)*(fM - fm))/(gM - gm) + fm;
old = AbsoluteOptions[
Plot[g, {x, min, max}, Frame -> True, PlotRange -> grange,
DisplayFunction -> Identity], FrameTicks][[1, 2, 2]];
new = (Prepend[Rest[#1], scale[First[#1]]] &) /@ old;
Plot[{f, scale[g]}, {x, min, max}, Frame -> True,
PlotRange -> frange + {0, .05 (fM - fm)},
FrameTicks -> {Automatic, Automatic, None, new},
PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 1]}},
FrameStyle -> {{}, {RGBColor[1, 0, 0]}, {}, {RGBColor[0, 0, 1]}},
opts]]
TwoAxisPlot[{x^3, Sqrt[x]}, {x, 0, 4}, {0, 64}, {0, 2}]
TwoAxisPlot[{Sqrt[x], x^3}, {x, 0, 4}, {0, 2}, {0, 70}]

Out[1]= "6.0 for Mac OS X x86 (64-bit) (May 21, 2008)"

[... graphics deleted ...]


Regardss,
-- Jean-Marc


  • Prev by Date: Re: Functional programming?
  • Next by Date: Solving algebraic equations with some conditions
  • Previous by thread: Advanced plotting
  • Next by thread: Re: Advanced plotting