Skip to content

lattice plots question

3 messages · Laura Holt, Sundar Dorai-Raj, Martin Maechler

#
Dear R People:

Is there any way to have the background of lattice plots be white instead of 
grey, please?

This is not a criticism by any means...the lattice stuff is UNbelievable!

Thanks,
Laura Holt
mailto: lauraholt_983 at hotmail.com

R Version 2.1.0 Windows
#
Laura Holt wrote:
Hi, Laura,

See ?trellis.par.set or ?trellis.device. Lattice themes are what you are 
looking for.

e.g.

library(lattice)
trellis.device(windows, theme = col.whitebg())
xyplot(0 ~ 0)

You can also create your own themes, which I find extremely useful:

sundar.theme <- function() {
   par <- col.whitebg()
   par$strip.background$col <- rep("#000099", 7)
   par$add.text$col <- "#eeeeaa"
   par$add.text$font <- 2
   par$background$col <- "#ffffff"
   par$superpose.line$lty <- rep(1, 7)
   par$superpose.line$col[1:2] <- c("#880000", "#008800")
   par$superpose.symbol$col[1:2] <- c("#880000", "#008800")
   par
}

HTH,

--sundar
#

        
Sundar> Laura Holt wrote:
>> Dear R People:
    >> 
    >> Is there any way to have the background of lattice plots be white 
    >> instead of grey, please?
    >> 
    >> This is not a criticism by any means...the lattice stuff is UNbelievable!

indeed, it is!

    >> ....



    Sundar> See ?trellis.par.set or ?trellis.device. Lattice
    Sundar> themes are what you are looking for.

    Sundar> e.g.

    Sundar> library(lattice)
    Sundar> trellis.device(windows, theme = col.whitebg())
    Sundar> xyplot(0 ~ 0)

If, instead of line 2, you use   
    trellis.device(theme = col.whitebg())

i.e., don't specify the device explicitly, you have solution that is
portable {across platforms} : The device chosen will depend if
you are in interactive or batch mode {which is good!} and
in interactive mode will use 'windows', 'x11' , or 'quartz'
depending on your platform --- as a matter of fact, it will be
what you also get by  getOption("device")
and you can change by  options(device = "myfavoriteDevice")
			      

    Sundar> You can also create your own themes, which I find extremely useful:

indeed!

    Sundar>  sundar.theme <- function() {
    Sundar>     ..............

Martin Maechler, ETH Zurich