s-news
[Top] [All Lists]

Re: Axis at the same scale

To: Tristan Lorino <tristan.lorino@lcpc.fr>, s-news@lists.biostat.wustl.edu
Subject: Re: Axis at the same scale
From: "Richard M. Heiberger" <rmh@temple.edu>
Date: Mon, 30 Jan 2006 09:20:10 -0500
## There are two distinct things you must do to control the axes.
## a. determine the range for each panel.
## b. determine the tick marks and labels.
## You are doing only the second of them.

## This example controls the range by using points(), not plot() for
## each panel.  Another alternative is to use par(yaxs="d") to lock
## the axis settings.  A third alternative, also shown below, and the
## one I would probably use, is to use trellis.

x1 <- rnorm(5)
x2 <- rnorm(5)
x3 <- rnorm(5)
x4 <- rnorm(5)

y1 <- rnorm(5)
y2 <- rnorm(5)
y3 <- rnorm(5)
y4 <- rnorm(5)


par(mfrow=c(2,2))
plot(x=range(c(x1,x2,x3,x4)),
     y=range(c(y1,y2,y3,y4)),
     type="n",
     axes=F,
     xlab="",
     ylab="")


points(x1, y1, col=2)
axis(1) 
axis(2,at=c(.6,.8,1,1.2,1.4,1.6,1.8,2),c
("0,60","0,80","1,00","1,20","1,40","1,60","1,80","2,00"),adj=.8) 
box() 

frame()
points(x2, y2, col=2)
axis(1) 
axis(2,at=c(.6,.8,1,1.2,1.4,1.6,1.8,2),c
("0,60","0,80","1,00","1,20","1,40","1,60","1,80","2,00"),adj=.8) 
box() 

frame()
points(x3, y3, col=2)
axis(1) 
axis(2,at=c(.6,.8,1,1.2,1.4,1.6,1.8,2),c
("0,60","0,80","1,00","1,20","1,40","1,60","1,80","2,00"),adj=.8) 
box() 

frame()
points(x4, y4, col=2)
axis(1) 
axis(2,at=c(.6,.8,1,1.2,1.4,1.6,1.8,2),c
("0,60","0,80","1,00","1,20","1,40","1,60","1,80","2,00"),adj=.8) 
box() 


tmp <- data.frame(x=c(x1,x2,x3,x4),
                  y=c(y1,y2,y3,y4),
                  group=factor(c(
                    rep(1, length(x1)),
                    rep(2, length(x2)),
                    rep(3, length(x3)),
                    rep(4, length(x4)),
                    )))
xyplot(y ~ x | group, data=tmp,
       as.table=T,
       scales=list(
         y=list(at=c(.6,.8,1,1.2,1.4,1.6,1.8,2),
           labels=c("0,60","0,80","1,00","1,20","1,40",
             "1,60","1,80","2,00"),
           adj=.8,
           alternating=F),
         x=list(alternating=F)),
       between=list(x=1, y=1))

<Prev in Thread] Current Thread [Next in Thread>