I\'m trying to get the background colors of the strips to change (it is a 6 by 6 matrix and i have 6 strip colors stocked in a vector named cola). I\'ve tried to combine thi
This code (quickly adapted from my answer to this SO question) gets you part of the way to a solution. (I'd be interested to learn whether/how it can be adapted to also print text in the each of the strips).
One thing to note is that the customized strip function need to be passed directly to useOuterStrips(), rather than to the nested call to bwplot().
# Create a function to be passes to "strip=" argument of xyplot
myStripStyle <- function(which.panel, factor.levels, ...) {
panel.rect(0, 0, 1, 1,
col = bgColors[which.panel],
border = 1)
## This call to panel.text() commented out because it does not
## work as I would have expected/hoped it to
# panel.text(x = 0.5, y = 0.5,
# font=2,
# lab = factor.levels[which.panel],
# col = "black")
}
mycola <- rainbow(6)
bgColors <- mycola
useOuterStrips(bwplot(~B$ylab|B$g1*B$g2,ylab="",xlab="",as.table=TRUE,
panel=function(...,bg){
panel.fill(col=mycol[panel.number()])
},
scale=list(draw=FALSE)),
strip = myStripStyle,
strip.left = myStripStyle)
