Re: Aligning subplots nicely?
- To: mathgroup at smc.vnet.net
- Subject: [mg31691] Re: [mg31659] Aligning subplots nicely?
- From: BobHanlon at aol.com
- Date: Sat, 24 Nov 2001 16:44:07 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 2001/11/23 8:30:02 AM, shsmolan at cc.hut.fi writes: >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? > One approach is to pad out the short axes labels to be the same length as the others. {p1,p2}={ Plot[x^2,{x,0,1}, DisplayFunction -> Identity], Plot[x^2,{x,0,0.1}, DisplayFunction -> Identity]}; Show[ GraphicsArray[{ p1 /. (Ticks -> Automatic) :> (Ticks -> {Automatic, (Ticks /. AbsoluteOptions[p1])[[2]] /. {x_?NumericQ, lab_, rem__} :> {x, PaddedForm[lab, {3, 3}], rem}}), p2}], DisplayFunction -> $DisplayFunction, ImageSize -> 440]; Bob Hanlon Chantilly, VA USA