MathGroup Archive 1996

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

Search the Archive

Re: Aligning Graphs in GraphicsArray

Dirk Kautz <kautz at>
in [mg3882] Aligning Graphs in GraphicsArray

asks, does anybody know how to align the y-axes of plots with ticks  
of different width in a GraphicsArray ?
Example: in
Show[GraphicsArray[{{Plot[x,{x,0,100}]},{Plot[100 x,{x,0,100}]}}]]
the Y-Axes don't align, and ask for a way round this


Below are two ways of dealing with your example - they may provide  
a basis for a more general solution.

Allan Hayes
hay at


	g1 =Plot[x,{x,0,100}]
	g2 =Plot[100 x,{x,0,100}]

We need to pad out the y-axis tick labels in g1 with spaces at the  
front so that they are as long as the longest y-axis label in g2,  
which is 10000.

Find the primitives used for the ticks in g1
	fg1 = FullGraphics[g1]
Look inside -Graphics- by evaluating
By inspection identify the index of the y-ticks definition as   
1,2,4 and pad the tick labels  as  required.
	pg1 =
	      (#/.Text[n_?NumberQ, r__] :> Text[PaddedForm[n,5],r])&,
It seems that we need to use PlotRange -> All to display the tick  
labels fully.
	sg1 = Show[pg1, PlotRange ->All];
Test in the array:

Alternatively we can use FullOptions.
The steps are similar.
	ytks = FullOptions[g1, Ticks][[2]];
Pad the labels (a little twist is that we have to use Round to get  
integer labels)
	pytks =
	  {n_,p_?NumberQ, r___} :> {n,PaddedForm[Round[p],5]}
Show tha modified g1
	sog1 = Show[g1, Ticks -> {Automatic, pytks}];

Check the array


  • Prev by Date: Re: how to draw the contour lines on a surface
  • Next by Date: Re: mathematica in C
  • Previous by thread: Re: Aligning Graphs in GraphicsArray
  • Next by thread: Help on a function (or a program really)