[R] Set panel background color in a multi-group trellis plot
crmontes at ncsu.edu
crmontes at ncsu.edu
Fri Nov 30 20:55:37 CET 2007
Thanks,
I'll finaly figure it out. It was not very intuitive though, even looking
at the help file. The final code, for whom it might interest is:
xyplot(Volume ~ Age|Farm,
groups = Treatment,
data = my_data,
panel = panel.superpose,
panel.groups = function(x,y, group.number, ...)
{
if (group.number == 1)panel.fill(col = "white")
panel.grid(col = "gray",lty = 2)
panel.xyplot(x,y,...)
}
Cristián Montes
NCState University
> Read ?panel.superpose carefully and pay attention to the comments about
> the
> group.number argument passed to panel.groups. You can test the value of
> this
> argument and adjust the plot accordingly.
>
>
>
> Bert Gunter
> Genentech Nonclinical Statistics
> 7-7374
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On
> Behalf Of crmontes at ncsu.edu
> Sent: Friday, November 30, 2007 8:50 AM
> To: r-help at r-project.org
> Subject: [R] Set panel background color in a multi-group trellis plot
>
> 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,...)
> }
>
More information about the R-help
mailing list