[R] lattice different colors in different areas

Paul Murrell p.murrell at auckland.ac.nz
Sun Apr 5 22:17:38 CEST 2009


Hi


William Deese wrote:
> In making grid graphs, one can make the background semi-transparent
> with a line like
> 
> grid.rect(gp=gpar(lty=0, fill=rgb(.5, .5, 0,. 25)))
> 
> and then make the area where points and lines are plotted white with lines like
> 
> pushViewport(plotViewport(c(5,4,3,1)))
> pushViewport(dataViewport(year, m, name="plotRegion"))
> grid.rect(gp=gpar(fill="white"))
> 
> (The area where the labels, title, legend, etc. are remains semi-transparent.)
> 
> I need to use the features of lattice for some graphs but want to keep
> the same color theme. In lattice, the background can be changed with
> the lines below, but it makes the entire graph this color.
> 
>     bsettings=trellis.par.get("background")
>     bsettings$col=rgb(.5, .5, 0, .25)
>     trellis.par.set("background", bsettings)
> 
> How do I now change just the plot region back to white?


Like this ... ?


xyplot(1:10 ~ 1:10,
       panel=function(...) {
         grid.rect(gp=gpar(fill="white"))
         panel.xyplot(...)
       },
       par.settings=list(background=list(col=rgb(.5, .5, 0, .25))))


Paul


> Thanks.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
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