Douglas M. Hultstrand
2009-Oct-22 17:46 UTC
[R] Cairo package, png files within for loop are black?
Hello, I am generating .png images using the Cairo package in a for loop (looping on the number of zones, number of zones equals the number of plots to create based on different zone data). When I run the R script the .png files are created but they are all black? If I comment out the for loop and force my zones to equal one the png file is created correctly? Is there an issue with generating .png files within a for loop? Create .png commands within for loop: CairoPNG(paste(t.g), width=800, height=600, pointsize=12, bg="white") xyplot(areasqmi ~ value, x.p, groups=dur, main=(t.n), ylab=expression("Area(mi" ^ 2 * ")"), xlab="Maximum Average Depth of Percipitation (inches)", scales=list(y=list(log=TRUE)), ylim=c(1,1000000), type='l', auto.key=list(space='right')) dev.off() -- --------------------------------- Douglas M. Hultstrand, MS Senior Hydrometeorologist Metstat, Inc. Windsor, Colorado voice: 970.686.1253 email: dmhultst at metstat.com web: http://www.metstat.com
Douglas Bates
2009-Oct-22 18:02 UTC
[R] Cairo package, png files within for loop are black?
On Thu, Oct 22, 2009 at 12:46 PM, Douglas M. Hultstrand <dmhultst at metstat.com> wrote:> Hello, > > I am generating .png images using the Cairo package in a for loop (looping > on the number of zones, number of zones equals the number of plots to create > based on different zone data). ? When ?I run the R script the .png files are > created but they are all black? ?If I comment out the for loop and force my > zones to equal one the png file is created correctly? ?Is there an issue > with generating .png files within a for loop?Probably not. The behavior you observe is due to a lattice graphics function being called in a loop. When called within a loop you must "print" or "show" the result of a lattice graphics function. See FAQ 7.22> Create .png commands within for loop: > > CairoPNG(paste(t.g), width=800, height=600, pointsize=12, bg="white") > ? xyplot(areasqmi ~ value, x.p, groups=dur, > ? main=(t.n), ylab=expression("Area(mi" ^ 2 * ")"), > ? xlab="Maximum Average Depth of Percipitation (inches)", > ? scales=list(y=list(log=TRUE)), ylim=c(1,1000000), type='l', > ? auto.key=list(space='right')) > dev.off() > > -- > --------------------------------- > Douglas M. Hultstrand, MS > Senior Hydrometeorologist > Metstat, Inc. Windsor, Colorado > voice: 970.686.1253 > email: dmhultst at metstat.com > web: http://www.metstat.com > > ______________________________________________ > 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. >