       Re: Two independent y axes ?

• To: mathgroup at smc.vnet.net
• Subject: [mg65417] Re: Two independent y axes ?
• From: Peter Pein <petsie at dordos.net>
• Date: Fri, 31 Mar 2006 06:09:10 -0500 (EST)
• References: <e0dpa6\$q91\$1@smc.vnet.net> <e0gcm6\$i5k\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Geico Caveman schrieb:
> Bill Rowe wrote:
>
>> On 3/27/06 at 6:56 AM, spam at spam.invalid (Geico Caveman) wrote:
>>
>>> I am trying to plot a bunch of functions and some data together.
>>> Some of the data and some of the functions have *very* different y
>>> range from the others. How do I create 2 independent y axes (like
>>> gnuplot - y and y2 axes) to show the data effectively ?
>> Is something like the following what you are looking for
>>
>> In:=
>> x = Sort[Table[Random[], {10}]];
>> y = 20*Reverse[Sort[Table[Random[], {10}]]];
>>
>> In:=
>> Show[Block[{\$DisplayFunction = Identity},
>>     {ListPlot[Rescale[x], PlotStyle -> Blue],
>>      ListPlot[Rescale[y], PlotStyle -> Red]}],
>>    Frame -> True, FrameTicks -> {Automatic,
>>      Range[0, 1, 0.2], None, ({#1, 20*#1} & ) /@
>>       Range[0, 1, 0.2]}];
>>
>> --
>> To reply via email subtract one hundred and four
>
> No. I am plotting velocity and acceleration for a particle as a function of
> time. These are physically distinct quantities and cannot share a y axis.
> Having colorful legends will not cut it.
>
I guess it was exacly that point, which caused Bill to propose a plot with 2 distinct y-axes (as you asked for) and not with any legend at all (as you see there).
Have you got some kind of "unruly" Mathematica? ;-)

Unfortunately, Bill's scaling is not correct: He rescales the random values from - say - [0.05,0.87]/[1.89,18.24] to [0,1], but scales the ticks from [0,1] to [0,1]/[0,20].

x = Sort[Table[Random[], {10}]];
y = 20*Reverse[Sort[Table[Random[], {10}]]];

With[{rg=Range[0, 1, 0.2], scal = Function[{v,r,n,f},
{#, NumberForm[Min[v] + #*(Max[v] - Min[v]), {n,f}]}&/@r]},
Show[Block[{\$DisplayFunction = Identity},
{ListPlot[Rescale[x], PlotStyle -> {AbsolutePointSize, Blue},
PlotJoined -> True],
ListPlot[Rescale[y], PlotStyle -> {AbsolutePointSize, Red},
PlotJoined -> True]}], Frame -> True,
FrameTicks -> {Automatic, scal[x,rg,3,2], None, scal[y,rg,4,2]},
FrameStyle -> List /@ {Black, Blue, Black, Red},
PlotRange -> {All, {-0.05, 1.05}}, Axes -> None]];

Peter

```

• Prev by Date: Re: Bug with Series[] - help wanted
• Next by Date: Re: Implicit integration of finite alternating series of hypergeometric (2F1) functions
• Previous by thread: Re: Two independent y axes ?
• Next by thread: Re: Two independent y axes ?