[R] Set panel background color in a multi-group trellis plot
crmontes at ncsu.edu
crmontes at ncsu.edu
Fri Nov 30 17:49:33 CET 2007
Hi everyone,
I am trying to change some of the default colors in a
multipanel-multigroup lattice graphic, but when I change the panel color
to white, the only group that is plotted is the last one, as panel.fill
overwrites all the previous ones. Is there any way to set the panel
background color for the first panel to a color and keep the rest
transparent?
My code looks like this:
#first set defaults for getting more distinct symbols
superp.symbol <- trellis.par.get("superpose.symbol")
superp.symbol$pch = 15:21
superp.symbol$cex = 1.5
trellis.par.set("superpose.symbol", superp.symbol)
#set the default for the colors in the symbols
superp.lines <- trellis.par.get("superpose.line")
superp.lines$lty <- 1:6
superp.lines$lwd <- 1.5
trellis.par.set("superpose.line", superp.lines)
#set the device color to lightblue
trellis.par.set("background", list(col = "lightblue"))
xyplot(Volume ~ Age|Farm,
groups = Treatment,
data = my_data,
panel = panel.superpose,
panel.groups = function(x,y, ...)
{
panel.fill(col = "white")
panel.grid(col = "gray",lty = 2)
panel.xyplot(x,y,...)
}
,auto.key = list(location = "bottom"),
main = "Main effects")
If I try to do something like
if (panel.group == 1) panel.fill(col = "white")
I get an error saying panel.group doesn't exist.
Any thoughts?
Regards,
Cristián Montes
NC State University
More information about the R-help
mailing list