Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5092

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

From "David Park" <djmpark@comcast.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Plot axis length and size ratio (TwoPlot revive)
Date 2011-09-20 10:13 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j59p12$q7$1@smc.vnet.net> (permalink)
References <27663898.180702.1316428706866.JavaMail.root@m06>

Show all headers | View raw


Matyi,

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
curves.

<< Presentations`

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

Draw2D[
 {Draw[2.5 x Sin[x], {x, 0, 10}],
  Red,
  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.

http://www.st-andrews.ac.uk/~pl10/c/djmpark/ 


David Park
djmpark@comcast.net
http://home.comcast.net/~djmpark/  


From: matyigtm [mailto:matyigtm@gmail.com] 

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




Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Plot axis length and size ratio (TwoPlot revive) "David Park" <djmpark@comcast.net> - 2011-09-20 10:13 +0000
  Re: Plot axis length and size ratio (TwoPlot revive) matyigtm <matyigtm@gmail.com> - 2011-09-21 09:32 +0000

csiph-web