MathGroup Archive 1996

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

Search the Archive

Re: Aligning Graphs in GraphicsArray

In article <4m1hki$pq4 at>, Dirk Kautz
<kautz at> wrote:

> Hi, does anybody know how to align the y-axes of plots with ticks of different
> width in a GraphicsArray ?
> In this simple example:
> Show[GraphicsArray[{{Plot[x,{x,0,100}]},{Plot[100 x,{x,0,100}]}}]]
> Y-Axes don't align. I'm sure somebody has solved this - thanks in
advance for any
> help on this!
> Dirk

The following is taken from the Technical Support FAQ area 
of Wolfram Research's Web pages.  The exact URL is:

The function TickFunction (as described in the ExtendGraphics package)
will allow you to create functions that generate ticks with
special formatting. This package is available from MathSource (item number

Here is an example. First, here are two plots with the same x-scale but
different y-scales. Note that because the tick labels are wider in
the second plot, the graphs are not aligned when placed in a GraphicsArray. 

In[1]:= Show[GraphicsArray[{
           {Plot[    x, {x, 0, 100}, DisplayFunction -> Identity]},
           {Plot[100 x, {x, 0, 100}, DisplayFunction -> Identity]}}]]
Out[1]= -GraphicsArray-

We load the Ticks package. 

In[2]:= Needs[ "ExtendGraphics`Ticks`"];

The following two lines defines the function setTickWidth, which uses
PaddedForm to format the numbers to print out leaving room
for exactly n digits. 

In[3]:= textFormat[n_][t_] := PaddedForm[N[#],n]& /@ t

In[4]:= setTickWidth[n_][min_,max_] := TickFunction[min,max,
                                       TextFunction-> textFormat[n]]

In the the above example, the largest tick label was 5 digits wide. Hence,
we use setTickWidth[5] as the value for the TickFunction

In[5]:= Show[GraphicsArray[{
            {Plot[x, {x, 0, 100},
                    DisplayFunction -> Identity,
                    Ticks -> setTickWidth[5]]},
            {Plot[100 x, {x, 0, 100},
                    DisplayFunction -> Identity,
                    Ticks -> setTickWidth[5]]}}]] 
Out[5]= -Graphics-

The ExtendGraphics packages are descibed in greater detail in 
Tom Wickham-Jones book "Mathematica Graphics: Techniques &
Applications" (TELOS/Springer-Verlag, 1994).

This and many other frequently asked questions about Mathematica
is answered in the Technical Support FAQ area of the Wolfram 
Research Web pages <>.

I hope this helps.


Ian Collier
Wolfram Research, Inc.
tel:(217) 398-0700   fax:(217) 398-0747    ianc at
Wolfram Research Home Page:


  • Prev by Date: Re: MathLink and Pascal ?
  • Next by Date: Re: Aligning Graphs in GraphicsArray
  • Previous by thread: Aligning Graphs in GraphicsArray
  • Next by thread: Re: Aligning Graphs in GraphicsArray