Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Combining Plots with Different Ordinate Axes in

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94971] Re: [mg94953] Combining Plots with Different Ordinate Axes in
  • From: Buz Barstow <buzb at mac.com>
  • Date: Thu, 1 Jan 2009 07:27:46 -0500 (EST)
  • References: <200812311110.GAA13681@smc.vnet.net>

Hi Bobby,

Thanks a lot for your help.

That code worked on my Mac. Unfortunately, I tried to make use of the  
code with ListPlot, but couldn't get the ticks to tick marks and tick  
labels to show up on the top edge of the frame.

Here's what I tried:

hSlideSeps = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.,  
1.1, 1.2, 1.3, 1.4, \
1.5, 1.6, 1.7, 1.8, 1.9}

vSlideSeps = {2., 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.,  
3.1, 3.2, 3.3, 3.4, \
3.5, 3.6, 3.7, 3.8, 3.9}

hSlideEnergies={1.933, 1.933, 1.933, 1.934, 1.934, 1.935, 1.937,  
1.938, 1.94, 1.941, 1.942, \
1.944, 1.946, 1.947, 1.949, 1.95, 1.951, 1.952, 1.954, 1.955}

vSqueezeEnergies={0.99, 0.269, 0.456, 1.044, 1.186, 1.313, 1.437,  
1.548, 1.643, 1.721, 1.783, \
1.832, 1.87, 1.898, 1.918, 1.933, 1.943, 1.95, 1.955, 1.958}

range1 = {0, 1.9};
range2 = {2.0, 3.9};
map = Interpolation[Transpose@{range1, range2}, InterpolationOrder ->  
1];

With[
  {range3 = Flatten@{x, range1},
   top = {#, Round[map@#, 0.01]} & /@ Range[Sequence @@ range1, 0.5]},
  plot1 = ListPlot[Transpose[{vSqueezeSeps, hSlideEnergies}], Joined - 
 > True];
  plot2 = ListPlot[Transpose[{vSqueezeSeps, vSqueezeEnergies}],
    Joined -> True];
  Show[plot2, plot1, PlotRange -> All, Axes -> False, PlotRange -> All,
   Frame -> True, FrameTicks -> {{Automatic, Automatic}, {Automatic,  
top}}]]


Am I doing something dumb?

Thanks! and all the best,

--Buz


On Dec 31, 2008, at 4:19 PM, DrMajorBob wrote:

> For instance,
>
> range1 = {0, 1.9};
> range2 = {2.5, 3.5};
> map = Interpolation[Transpose@{range1, range2},
>   InterpolationOrder -> 1];
>
> With[{range3 = Flatten@{x, range1},
>  top = {#, Round[map@#, 0.01]} & /@ Range[Sequence @@ range1, 0.5]},
> p1 = Plot[Sin[x], range3, PlotStyle -> Red];
> p2 = Plot[Cos[map@x], range3, PlotStyle -> Blue];
> Show[p1, p2, PlotRange -> All, Axes -> False, PlotRange -> All,
>  Frame -> True,
>  FrameTicks -> {{Automatic, Automatic}, {Automatic, top}}]
> ]
>
> ??
>
> Bobby
>
> On Wed, 31 Dec 2008 05:10:51 -0600, Buz Barstow <buzb at mac.com> wrote:
>
>> Hi All,
>>
>> I'd like to combine two plots in Mathematica that have different x
>> axes, but have similar y axes.
>>
>> In the first plot, the x range runs from 0 to 1.9, while in the  
>> second
>> plot the x values run from 2.5 to 3.5.
>>
>> I'd like to combine these plots together, and have one set of x  
>> values
>> displayed on the top edge of a frame, and the other set of x values
>> displayed on the bottom edge of the frame.
>>
>> Both plots can have a common y axis.
>>
>> Thanks! and all the best,
>>
>> --Buz
>>
>>
>>
>
>
>
> -- 
> DrMajorBob at longhorns.com



  • Prev by Date: Re: Converting 2D Lists to 3D lists
  • Next by Date: Re: Combining Plots with Different Ordinate Axes in
  • Previous by thread: Re: Combining Plots with Different Ordinate Axes in
  • Next by thread: Re: Combining Plots with Different Ordinate Axes in