Hi all, I'm having a problem creating png images with trellis.device. I would like to create many plots with a white background using a sequence number in the file argument (i.e. "%02d"). The first plot is as expected with a white background. However, the second and all subsequent plots have a gray background. I would like all plots to have a white (or transparent) background. Below is an example: library(lattice) z <- expand.grid(A = LETTERS[1:8], B = letters[1:6]) z$x <- z$y <- rep(1, nrow(z)) trellis.device(png, file = "test%02d.png", bg = "white") lset(col.whitebg()) xyplot(y ~ x | A * B, data = z, layout = c(4, 6)) dev.off() This is also the case for jpeg and bmp though win.metafile and postscript do not have this problem. Is this a bug or am I missing something obvious? I found one reference that implies this may be expected behaviour but I'm not sure if I interpretted the comment correctly. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/18890.html > R.version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 9.1 year 2004 month 06 day 21 language R > help(package = lattice) Information on Package 'lattice' Description: Package: lattice Version: 0.9-12 Date: 2004/06/01 <snip>
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> packageDescription("lattice")Package: lattice Version: 0.9-16 Date: 2004/07/07 Priority: recommended Title: Lattice Graphics Author: Deepayan Sarkar <deepayan at stat.wisc.edu> Maintainer: Deepayan Sarkar <deepayan at stat.wisc.edu> Description: Implementation of Trellis Graphics. See ?Lattice for a brief introduction Depends: R (>= 1.9.0), grid License: GPL version 2 or later Packaged: Wed Jul 7 02:39:54 2004; deepayan Built: R 1.9.1; i386-pc-mingw32; 2004-07-07 14:00:16; windows -- File: C:/R/rw1091/library/lattice/DESCRIPTION Andy> From: Sundar Dorai-Raj > > Hi all, > I'm having a problem creating png images with > trellis.device. I would > like to create many plots with a white background using a sequence > number in the file argument (i.e. "%02d"). The first plot is > as expected > with a white background. However, the second and all subsequent plots > have a gray background. I would like all plots to have a white (or > transparent) background. Below is an example: > > library(lattice) > z <- expand.grid(A = LETTERS[1:8], B = letters[1:6]) > z$x <- z$y <- rep(1, nrow(z)) > trellis.device(png, file = "test%02d.png", bg = "white") > lset(col.whitebg()) > xyplot(y ~ x | A * B, data = z, layout = c(4, 6)) > dev.off() > > This is also the case for jpeg and bmp though win.metafile and > postscript do not have this problem. Is this a bug or am I missing > something obvious? > > I found one reference that implies this may be expected behaviour but > I'm not sure if I interpretted the comment correctly. >http://finzi.psych.upenn.edu/R/Rhelp02a/archive/18890.html > R.version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 9.1 year 2004 month 06 day 21 language R > help(package = lattice) Information on Package 'lattice' Description: Package: lattice Version: 0.9-12 Date: 2004/06/01 <snip> ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Hello: I was able to get two graphs with white background in JPG format, but only the first graph with PNG format (as previously remarked). Curiously, I only got the first graph saved (with white background) for the PDF format. Code follows... ANDREW library(lattice) z <- expand.grid(A = LETTERS[1:8], B = letters[1:6]) z$x <- z$y <- rep(1, nrow(z)) png(file = "~/tmp/test%02d.png") lset(theme = col.whitebg()) xyplot(y ~ x | A * B, data = z, layout = c(4, 6)) dev.off() jpeg(file = "~/tmp/test%02d.jpg") lset(theme = col.whitebg()) xyplot(y ~ x | A * B, data = z, layout = c(4, 6)) dev.off() pdf(file = "~/tmp/test%02d.pdf") lset(theme = col.whitebg()) xyplot(y ~ x | A * B, data = z, layout = c(4, 6)) dev.off() > version platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 1 minor 9.0 year 2004 month 04 day 12 language R