Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121619] Re: Plot axis length and size ratio (TwoPlot revive)
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Thu, 22 Sep 2011 07:27:01 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j5781h$jac$1@smc.vnet.net>

On Sep 19, 4:11 am, matyigtm <matyi... at gmail.com> wrote:
> Hi,
>
> 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 *
> 1.045]
>
> Any idea to align the two plots is appreciated,
> Matyi

It may take a little messing around to get values of shift, scale,
and tix that give you what you want, but something like this might
work for you.

With[{shift = 0, scale = .2, tix = Range[-20,20,5]},
Plot[{x Sin[x], shift + scale * x(x-10)Cos[x]},{x,0,10},
PlotStyle->{Black,Orange}, Frame->True, FrameLabel->{None,
"x Sin[x]  (black)", None, "x (x-10) Cos[x]  (orange)"},
FrameTicks->{Automatic, Automatic, None, {shift+scale*#,#}&/@tix}]]




  • Prev by Date: Re: Calculus and InterpolatingFunction
  • Next by Date: Re: Calculus and InterpolatingFunction
  • Previous by thread: Re: Plot axis length and size ratio (TwoPlot revive)
  • Next by thread: Error Message on Magnification