[R] Specifying strip.names in Lattice plots

Duncan Mackay dulcalma at bigpond.com
Wed Mar 5 02:51:21 CET 2014


Hi Rich

The first arguments for strip.default are

which.given, which.panel, var.name, factor.levels,

which means they take the names from the factors of each strip

without  a reproducible example here is something that may help

  data(esoph)
  
  levels(esoph$alcgp)


  xyplot(ncontrols ~ncases|alcgp, esoph,
         as.table = TRUE,
           par.settings = list(strip.background = list(col = "transparent"),
                               axis.text = list(cex = 0.65),
                               par.xlab.text = list(cex = 0.75),
                               par.ylab.text = list(cex = 0.75)
                          ),
          scales   = list(x = list(alternating = FALSE,
                                   relation    = "same",
                                   rot         = 0),
                          y = list(alternating = FALSE,
                                    relation    = "same",
                                    rot         = 0)
                     ),
           strip    = strip.custom(factor.levels = paste(gsub("[a-z/]","",
levels(esoph$alcgp)), "g/day"),
                                   par.strip.text = list(cex = 0.65) ),
         )

If you have multiple conditioning see 

library(latticeExtra)
?useOuterStrips

which have the arguments strip and strip.left there and you fill the text
there
levels(esoph$alcgp))

  useOuterStrips(strip      = strip.custom(factor.levels =
paste(gsub("[a-z/]","", levels(esoph$alcgp)), "g/day"),
                                           par.strip.text = list(cex =
0.75)),
                 strip.left = strip.custom(factor.levels =
as.character(levels(esoph$agegp)),
                                           par.strip.text = list(cex =
0.75)),
  xyplot(ncontrols ~ncases|alcgp*agegp, esoph,
         as.table = TRUE,
           par.settings = list(strip.background = list(col = "transparent"),
                               axis.text = list(cex = 0.65),
                               par.xlab.text = list(cex = 0.75),
                               par.ylab.text = list(cex = 0.75)
                          ),
          scales   = list(x = list(alternating = FALSE,
                                   relation    = "same",
                                   rot         = 0),
                          y = list(alternating = FALSE,
                                    relation    = "same",
                                    rot         = 0)
                     ),
         )
  ) ## useOuterStrips

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Rich Shepard
Sent: Wednesday, 5 March 2014 05:49
To: r-help at r-project.org
Subject: [R] Specifying strip.names in Lattice plots

   I've read Deepayan's book, ?strip, and ?strip.default, without learning
how to specify strip names on xyplots. The following command produces the
attached plot:

xyplot(cbind(dalles.disch.ts, dalles.temp.ts), strip.left, main = "Columbia
River @ The Dalles", xlab = "Date (Year.Month)", ylab = c("Temperature
(C)","Discharge (cfs)"))

   However, when I try to specify names for each strip using panel functions
I either get a blank plot or error messages. What I want to learn how to do
is either 1) put the ylab in the strip or 2) eliminate the strip as
redundant.

TIA,

Rich




More information about the R-help mailing list