[R] change lattice panel background color
Paul Murrell
p.murrell at auckland.ac.nz
Sun Jan 22 22:51:26 CET 2006
Hi
Waichler, Scott R wrote:
> I can't find a way to change just the panel background color in lattice.
> I would like NA regions in levelplot() to appear black. I've tried the
> trellis.par.set() stuff, but it it makes the background of the whole
> graphic black.
Here's an approach using a simple custom panel function (mind the wrap)...
# Slight modification of example from ?levelplot
require(stats)
attach(environmental)
ozo.m <- loess((ozone^(1/3)) ~ wind * temperature * radiation,
parametric = c("radiation", "wind"), span = 1, degree = 2)
w.marginal <- seq(min(wind), max(wind), length = 50)
t.marginal <- seq(min(temperature), max(temperature), length = 50)
r.marginal <- seq(min(radiation), max(radiation), length = 4)
wtr.marginal <- list(wind = w.marginal, temperature = t.marginal,
radiation = r.marginal)
grid <- expand.grid(wtr.marginal)
grid[, "fit"] <- c(predict(ozo.m, grid))
grid[, "fit"][sample(1:10000, 100)] <- NA
library(grid)
levelplot(fit ~ wind * temperature | radiation, data = grid,
cuts = 10, region = TRUE,
xlab = "Wind Speed (mph)",
ylab = "Temperature (F)",
main = "Cube Root Ozone (cube root ppb)",
panel=function(...) {
grid.rect(gp=gpar(col=NA, fill="black"))
panel.levelplot(...)
})
Paul
> Thanks,
> Scott Waichler
> Pacific Northwest National Laboratory
> scott.waichler _at _ pnl.gov
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-help
mailing list