[R] multiple "keys" in Trellis plots?

Bartz, Kevin Kevin.Bartz at FMR.COM
Mon Sep 9 16:09:18 CEST 2002


My xyplot has a number of panels, and I'd like a separate key for each
rather than a single key for the entire set. However, I cannot find a way to
pass multiple key definitions to xyplot's "key" argument.

Allow me to throw out a simple example:

require(methods)
require(lattice)

## define sample data
myFrame1 <- data.frame(a=1:100, b=rep(1:10,10), c=unlist(lapply(1:10, rep,
10)))
myFrame2 <- data.frame(a=50:1,  b=rep(1:10,5),  c=unlist(lapply(1:5, rep,
10)))
myFrame  <- cbind(rbind(myFrame1, myFrame2),
                  which=c(rep("Display for myFrame1", 100),
                    rep("Display for myFrame2", 50)))

## now send the data to a Trellis device
trellis.device()
print(xyplot(a ~ b | which, myFrame, groups=c,
             key=list(text=list(lab=paste("myFrame1 Line", 1:10))),
             panel="panel.superpose", t="l"))

What I really want here is two separate keys, one for the plot on the first
panel, representing the lines in myFrame1, and one for the plot on the
second, representing the lines in myFrame2.

Can anyone suggest a solution?

Thanks,

Kevin

> R.version
         _                   
platform sparc-sun-solaris2.6
arch     sparc               
os       solaris2.6          
system   sparc, solaris2.6   
status                       
major    1                   
minor    5.1                 
year     2002                
month    06                  
day      17                  
language R                   
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list