MathGroup Archive 2011

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

Search the Archive

Re: Plot axis length and size ratio (TwoPlot revive)

  • To: mathgroup at
  • Subject: [mg121571] Re: Plot axis length and size ratio (TwoPlot revive)
  • From: "David Park" <djmpark at>
  • Date: Tue, 20 Sep 2011 06:09:40 -0400 (EDT)
  • Delivered-to:
  • References: <27663898.180702.1316428706866.JavaMail.root@m06>


This is how I would do it with the Presentations application. I would use a
Frame plot rather than an Axes plot. I think if you look in scientific
journals you will seldom see an axes plot where an axis cuts across the

<< Presentations`

yticks1 = CustomTicks[2.5 # &, {-8, 8, 4, 4}];
yticks2 = 
  CustomTicks[Identity, {-30, 30, 10, 5}, 
   CTNumberFunction -> (Style[#, Red] &)];

 {Draw[2.5 x Sin[x], {x, 0, 10}],
  Draw[x (x - 10) Cos[x], {x, 0, 10}]},
 AspectRatio -> 0.6,
 Frame -> True,
 FrameTicks -> {{yticks1, yticks2}, {Automatic, Automatic}},
 FrameLabel -> {x, y1, None, Style[y2, Red]}, RotateLabel -> False,
 PlotLabel -> "Two Axis Plot",
 BaseStyle -> {FontSize -> 12}]

First we define custom ticks for the two y axes. Then in a single Draw2D
drawing statement we draw the two curves, scaling y1 by a factor of 2.5.
Then we specify the overall look of the plot with options using the custom
ticks defined initially.

A notebook and PDF of this result will appear on the archive kept for me by
Peter Lindsay at St. Andrews University Mathematics Department. 

David Park
djmpark at  

From: matyigtm [mailto:matyigtm at] 


I want to combine two plots with the same "x" axis into one graphic.
Because the two plots have different magnitude, I choosed the "Inset"
command inside of one of the two plots. I want to put the two "y" axes
on left and right for the two plots, resp. (aka. TwoPlot)
My problem is that the two plots take different sizes when the numbers
written at the ticks on the "y" axis get different length, or when
AxesLabel is used. I've understood the the area of the plot is
extended by PlotRangePadding and with ImagePadding, but I cannot
retrieve the latter from the plots to get the right sizes.

The Inset command help a lot to position the origins of the two plots,
but its "size" parameter looses any relation to the coordinates used
in the plots.

The following example illustrates the problem, the hardcoded number
1.045 is to be programmed to give good results.

plt2 = Plot[x (x - 10) Cos[x], {x, 0, 10}, PlotStyle -> Red,
AxesOrigin -> {10, 0}, AxesStyle -> Red];
Plot[x Sin[x], {x, 0, 10},  Epilog -> Inset[plt2, {0, 0}, {0, 0}, 10 *

Any idea to align the two plots is appreciated,

  • Prev by Date: Re: "Traveling salesman on a hemisphere" problem
  • Next by Date: Re: Changing excel table with Wolfram Mathematica
  • Previous by thread: Plot axis length and size ratio (TwoPlot revive)
  • Next by thread: Re: Plot axis length and size ratio (TwoPlot revive)