s-news
[Top] [All Lists]

Re: Formatting trellis graphics

To: "Riley, Steve" <Steve.Riley@pfizer.com>
Subject: Re: Formatting trellis graphics
From: "Richard M. Heiberger" <rmh@temple.edu>
Date: Mon, 22 Aug 2005 17:27:06 -0400
Cc: "'s-news@lists.biostat.wustl.edu'" <s-news@lists.biostat.wustl.edu>
You can get all that you are asking for from trellis.
But it looks bad if you have more than one panel.  I will guess
therefore that it is intentionally difficult to turn the box
off.  Here are three plots.  the first is what you asked for.
The second and third show what happens with two panels.
Neither looks good.

As you can see, these are based on the previous responses to your query.

Rich




y <- c(1:10,1:10*2)
x <- c(rep(1:10,2))
id <- c(rep(1,10), rep(2,10))
trt <- rep(letters[1:2],5)
data <- cbind.data.frame(TIME = x, CONC = y, ID = id, treatment=trt)

 
par(bty="l")  ## get the "L" shaped box 
par(oma=c(4,2,2,2))            ##  This is to control the outer margin.
xyplot(CONC ~ TIME, data = data, 
       groups = ID,
       scale = list(x = list(draw = F), y = list(draw = F)),
       xlab="", ylab="",
       panel = function(x,y,subscripts,...) {
         panel.superpose(x,y,subscripts,type="b",...)
         axis(side=1, at=seq(2,10,2), labels=seq(2,10,2), font=2)
         axis(side=2, at=seq(5,20,5), labels=seq(5,20,5), font=3, adj=1)
       }
       )
## Add x and y labels.
mtext("Time", side = 1, outer = F, font =2, cex = 1.2, line=6)
mtext("CONC", side = 2, outer = F, font =2, cex = 1.2, line=5)
mtext(side=3, "This is how it looks with one panel.", outer=T)


xyplot(CONC ~ TIME | treatment, data = data, 
       groups = ID,
       scale = list(x = list(draw = F), y = list(draw = F)),
       xlab="", ylab="",
       panel = function(x,y,subscripts,...) {
         panel.superpose(x,y,subscripts,type="b",...)
         axis(side=1, at=seq(2,10,2), labels=seq(2,10,2), font=2)
         axis(side=2, at=seq(5,20,5), labels=seq(5,20,5), font=3, adj=1)
       }
       )
mtext(side=3, "This looks bad when there is more than one panel.", outer=T)


par(bty="o")  ## restore the "O" shaped box 
xyplot(CONC ~ TIME | treatment, data = data, 
       groups = ID,
       scale = list(x = list(draw = F), y = list(draw = F)),
       xlab="", ylab="",
       panel = function(x,y,subscripts,...) {
         panel.superpose(x,y,subscripts,type="b",...)
         axis(side=1, at=seq(2,10,2), labels=seq(2,10,2), font=2)
         axis(side=2, at=seq(5,20,5), labels=seq(5,20,5), font=3, adj=1)
       }
       )
mtext(side=3, "We now have excess tick labels.", outer=T)

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