MathGroup Archive 2001

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

Search the Archive

RE: Aligning subplots nicely?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31686] RE: [mg31659] Aligning subplots nicely?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 24 Nov 2001 16:43:58 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Sampo,

This is a weak area of Mathematica graphics. The problem is that Mathematica
gives no direct and sure method for controlling the label space around the
axes or frame of a plot. I have a notebook at my web site called
AlignedGraphics that gives some hints for aligning plots - but the methods
are far from what they should be.

In your example, better alignment can be obtained by forcing the labels,
specifically the y axes labels, to use the same space. Then the plots will
be similarly positioned within their rectangles.

yticks1 =
    Table[{y, NumberForm[y, {4, 3}, NumberPadding -> {"", "0"}]}, {y, 0.2,
1,
        0.2}];

yticks2 =
    Table[{y, NumberForm[y, {4, 3}, NumberPadding -> {"", "0"}]}, {y, 0.002,
        0.01, 0.002}];

{p1, p2} = {Plot[x^2, {x, 0, 1}, Ticks -> {Automatic, yticks1}],
      Plot[x^2, {x, 0, 0.1}, Ticks -> {Automatic, yticks2}]};

Show[GraphicsArray[{p1, p2}], ImageSize -> 500];

You could also use scaled tick labels on one graph and give the scaling
factor in a label. This would allow shorter labels for both plots.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

> From: Sampo Smolander [mailto:shsmolan at cc.hut.fi]
To: mathgroup at smc.vnet.net
>
> Is there a handy way to aling subplots nicely?
>
> For example, if I have
>
>   {p1, p2} = {Plot[x^2, {x, 0, 1}], Plot[x^2, {x, 0, 0.1}]}
>
> and then I do
>
>   Show[GraphicsArray[{p1, p2}]]
>
> Then the two subplots are of different size (because in p2 the
> numbers in y-axis are longer, and take relatively more or
> the rectangle that GraphicsArray assignes to the subplot),
> and the result looks ugly.
>
> I found out that I can do this:
>
> Show[Graphics[{Rectangle[{0, 0}, {1, 1}, kk1],
>                Rectangle[{1, -0.02}, {2.18, 1.05}, kk2]}]];
>
> It looks relatively nice (at leat in certain size),
> but I need lots of iterative handwork to tune the
> rectangle parameters.
>
> Any better ways?
>
> --
> Sampo Smolander, shsmolan at cc.hut.fi, http://www.hut.fi/u/shsmolan/
> ............"the more bottles we use, the closer we ought to come"
> ................ D.J. Griffiths: Introduction to Quantum Mechanics
>



  • Prev by Date: RE: Loop through a notebook
  • Next by Date: Re: Re: Zero does not equal zero et al.
  • Previous by thread: Re: Aligning subplots nicely?
  • Next by thread: Re: Aligning subplots nicely?