Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

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
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:
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[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
option. 

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 <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
Wolfram Research Home Page:         http://www.wolfram.com/
-----------------------------------------------------------

==== [MESSAGE SEPARATOR] ====


  • 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