[R] legend on trellis plot

From: Henrik Agersų <hkag_at_novonordisk.com>
Date: Wed 09 Aug 2006 - 21:14:23 EST

Dear all

I have two questions regarding trellis plots - which I hope you may be able to help me with.

Is it possible to place the key in a trellis plot on the panel (instead of beside the panel)? This will cause the same key to be reproduced on each panel. Please see the plot below - here I placed the legend below the plot. I tried moving the key to the function statement, but it did not really work out the way I expected.

One last thing, in the plot below I placed a horizontal line on the plot, is it possible to only have the horizontal line on the left panel (I remember that in S it was possible to state something like "if(get("cell",fr=9)==2)" in the function statement to include the line on only one of the panels)?

All suggestions will highly appreciated.

Br Henrik

###############################

data           <- as.data.frame(cbind(rep(1:4,each=25),
                  rep(1:2,each=50) ,rep(1:25,4),
                  rnorm(100,0,1) ))

names(data) <- c("ID","DOSE","TIME","DV")

xyplot(DV~TIME | DOSE, data=data, groups=ID, layout=c(2,1),

       key=list(space="bottom",border=TRUE,colums=2,text=list(c("ID1","ID2"),col=c(1,4)),
              lines=list(type="o",pch=c(1,16),lty=c(1,2), col=c(1,4)),
              layout.heights=list(key.axis.padding=15)),
           
       panel = function(x,y,groups,...) {
                 panel.superpose.2(x,y,groups,...,type="o",pch=c(1,16),
                 lty=c(1,2), col=c(1,4), cex=0.8)
                 panel.abline(h=0.301,col=5,lty=1,lwd=2)  
    }
)

###############################

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed Aug 09 21:19:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 09 Aug 2006 - 22:20:09 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.