MathGroup Archive 2009

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

Search the Archive

ListLogLinearPlot with two y-axis

  • To: mathgroup at
  • Subject: [mg102559] ListLogLinearPlot with two y-axis
  • From: pasQualle <pschulthess at>
  • Date: Fri, 14 Aug 2009 05:57:58 -0400 (EDT)

Hi everybody,

I came across a solution for the plotting of continuous functions with
two y-axis. I also found code to plot two lists with different ranges
into one figure with two y-axis, but the thing I need is to plot two
lists into one figure with two y-axis where the x-axis is in log.

So, the solution for the lists looks like:

TwoAxisListPlot[f_List, g_List, frange_, grange_, color1_, color2_,
  opts___?OptionQ] :=
 Module[{old, new, scale, fm, fM, gm, gM, newg}, {fm, fM} = frange;
  {gm, gM} = grange;
  scale[var_] := ((var - gm) (fM - fm))/(gM - gm) + fm;
  old = AbsoluteOptions[
     ListPlot[g, Frame -> True, PlotRange -> grange,
      DisplayFunction -> Identity], FrameTicks][[1, 2, 2]];
  new = (Prepend[Rest[#1], scale[First[#1]]] &) /@ old;
  newg =
     Map[scale, Transpose[g][[2]], {1, 2}]}];
  ListLinePlot[{f, newg}, Frame -> True,
   FrameTicks -> {Automatic, Automatic, None, new},
   PlotStyle -> {{color1}, {color2}},
   FrameStyle -> {{}, {color1}, {}, {color2}},
   PlotRange -> frange*(1 + .00 (fM - fm)), opts]]

And to plot the lists:

TwoAxisListPlot[data1, data2, {5, 8.3}, {450, 460}, Red, Blue,
Axes -> False, Joined -> {True, False},
PlotMarkers -> {Style[\[EmptyCircle], Red, Medium,
Background -> White],
Style[\[FilledUpTriangle], Blue, Medium]} ], {Style["X",
FontFamily -> Times],
Style["Y", Red, FontFamily -> Times]}, {Bottom, Left}],
Style["Y-alt", Blue, FontFamily -> Times], Right]

I'm really not that a Mathematica Pro to translate this for my
purpose. Can anyone of you help me with this?
I would really appreciate it.



  • Prev by Date: Re: How to get plot Exclusions for a numerical function?
  • Next by Date: Re: Number of Words in a String
  • Previous by thread: Re: Re: ParrallelDo and set::noval
  • Next by thread: Re: ListLogLinearPlot with two y-axis