[R] Cairo package, png files within for loop are black?

Douglas Bates bates at stat.wisc.edu
Thu Oct 22 20:02:35 CEST 2009


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




More information about the R-help mailing list