[R] gray background in png
Deepayan Sarkar
deepayan at stat.wisc.edu
Sun Jul 18 18:36:16 CEST 2004
On Sunday 18 July 2004 10:29, Liaw, Andy wrote:
> Seems like a bug to me. I tried setting theme=col.whitebg in
> arguments to trellis.device, same result. Setting
> options(lattice.theme=col.whitebg) also does the same thing. The
> same thing happens win.metafile() for me. This is on WinXPPro,
> R-1.9.1 and
Definitely a bug, but probably not where you would think. Note that
col.whitebg() is misnamed, the background is actually 'transparent'.
As far as I can make out, the first plot is the one that's wrong, all
the subsequent ones are fine. (The apparent 'grayness' of the
background is probably just a feature of your png displayer.)
The workaround depends on whether you really want a white or transparent
background.
For transparent:
library(lattice)
z <- expand.grid(A = LETTERS[1:8], B = letters[1:6], x = 1, y = 1)
trellis.device(png, file = "test%02d.png")
par(bg = "transparent")
lset(col.whitebg())
xyplot(y ~ x | A * B, data = z, layout = c(4, 6))
dev.off()
For white:
library(lattice)
z <- expand.grid(A = LETTERS[1:8], B = letters[1:6], x = 1, y = 1)
trellis.device(png, file = "test%02d.png")
par(bg = "white")
lset(col.whitebg())
lset(list(background = list(col = "white")))
xyplot(y ~ x | A * B, data = z, layout = c(4, 6))
dev.off()
The reason for this, I think, is that grid seems to use par("bg") for
the background of the first plot, but not for the rest. See, for
example. the results of
png(bg = "yellow")
grid.lines()
grid.newpage()
grid.lines()
dev.off()
I'll have to think about the best way to fix this.
Deepayan
More information about the R-help
mailing list