[R] Key titles in Lattice

Kuhn, Max Max.Kuhn at pfizer.com
Thu Jun 1 21:32:44 CEST 2006


Hi,

I'm creating some lattice plots that have a key and I'd like to put a
label on the key. The problem is that the text label for the key
prevents the values of the group variables from being shown (see example
below). I don't think that this is a feature, but I might be abusing the
title arg for key.

I'm using R Version 2.3.0 (2006-04-24) on Windows XP and lattice V0.13-8

Thanks,

Max


library(lattice)
testData <- expand.grid(
   A = letters[1:2], 
   B = letters[3:4], 
   C = letters[5:6])
testData$y <- rnorm(dim(testData)[1])

stripplot(
   y ~ A|B,  data = testData,
   groups = C,
   panel = function(x, y, groups, subscripts)
   {
      group.values <- sort(unique(groups))
      for (i in seq(along=group.values)) 
      {
         id <- (groups[subscripts] == group.values[i])
         current.val <- group.values[i]
         panel.stripplot(x[id], y[id],
            jitter.data = FALSE, horizontal = FALSE,
            col = trellis.par.get()$superpose.symbol$col[i], 
            pch = trellis.par.get()$superpose.symbol$pch[i])
         panel.linejoin(
            x[id], y[id], horizontal=F,
            col = trellis.par.get()$superpose.symbol$col[i], 
            lty = trellis.par.get()$superpose.line$lty[i], 
            lwd = trellis.par.get()$superpose.line$lwd[i])
      }
   }, 
   main = "Some Text", 
   key = list(
      columns = 2,
      text=list(
# comment the next line out to see 
# the values of the grouping variable
         title = "More Text",  
         lab = letters[5:6]),
      lines=list(
         col = trellis.par.get()$superpose.symbol$col[1:2],
         lwd = trellis.par.get()$superpose.line$lwd[1:2],
         lty = trellis.par.get()$superpose.line$lty[1:2]),
      points = list(
         col = trellis.par.get()$superpose.symbol$col[1:2],
         pch = trellis.par.get()$superpose.symbol$pch[1:2]))) 

----------------------------------------------------------------------
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}



More information about the R-help mailing list