       Re: Aligning Graphs in GraphicsArray

• To: mathgroup at smc.vnet.net
• Subject: [mg3905] Re: Aligning Graphs in GraphicsArray
• From: ianc (Ian Collier)
• Date: Sun, 5 May 1996 23:12:01 -0400
• Organization: Wolfram Research, Inc.
• Sender: owner-wri-mathgroup at wolfram.com

```In article <4m1hki\$pq4 at dragonfly.wolfram.com>, Dirk Kautz
<kautz at tyto.bio2.rwth-aachen.de> 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
> help on this!
>
> Dirk
>

The following is taken from the Technical Support FAQ area
of Wolfram Research's Web pages.  The exact URL is:
http://www.wolfram.com/support/Graphics/Axes/GraphicsArrayTicks/index.html

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
0205-041.)

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:= Show[GraphicsArray[{
{Plot[    x, {x, 0, 100}, DisplayFunction -> Identity]},
{Plot[100 x, {x, 0, 100}, DisplayFunction -> Identity]}}]]
Out= -GraphicsArray-

In:= 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:= textFormat[n_][t_] := PaddedForm[N[#],n]& /@ t

In:= 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 as the value for the TickFunction
option.

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

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

is answered in the Technical Support FAQ area of the Wolfram
Research Web pages <http://www.wolfram.com/support/>.

I hope this helps.

--Ian

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