[R] trellis: positioning of key

Christoph Scherber Christoph.Scherber at uni-jena.de
Wed Nov 9 16:24:23 CET 2005


Dear R users,

Using xyplot(), how can I position the key in the *margin* outside the 
plotting area ?

My problem is that the key always overlaps with the x axis labels, no 
matter how I try to specify any of the par() arguments (e.g. oma()).

Many thanks for any suggestions!
Christoph


###
for information, here´s the code I use

par(oma=c(0,0,3,0)) ###this, I think, is what should be changed

xyplot(jitter(height,factor=1) ~ sowndiv | time2,
       groups=treatment, data=caging04051, subscripts=T,
       xlab=list("Diversity",cex=1.5),
       ylab=list("Height",cex=1.5),
       layout=c(3, 1),

       key=list(space="top",border=TRUE,
         columns=1,
         transparent=FALSE,
         points=list(pch=c(1,2),cex=2),
         lines=list(col=c(1,1), lty=c(1,2), lwd=c(1.5,1.5)),
         text=list(levels(treatment), cex=1.2)),

       par.strip.text=list(cex=1.2),
           strip = function(..., strip.names)
           strip.default(..., strip.names=c(FALSE, TRUE),
                     style = 1),

       scales=list(  x=list(at=c(1, 2, 4, 8, 16, 60),
                       labels=c(1,2,4,8,16,60),log=TRUE,cex=1.4,tck=0.02),
                     y=list(tck=0.02)),

       panel=function(x, y, subscripts, groups){
         panel.superpose(x, y, subscripts, groups,cex=1.4)
         which <- groups[subscripts]
                panel.loess(x[which=="C"],y[which=="C"],lty=1)
                panel.loess(x[which=="H"],y[which=="H"],lty=2)
       })




More information about the R-help mailing list