hello all,
I got a problem with the rasterVis package.
I tried to do some plots in a loop and write every plot with Cairo to
disc. But the picture in the file on the disc is totaly black or a
white.
Do somebody know how to make png/pdf levelplots in a loop?
here is my test-script
# problem with RasterVis plots in loops
#
###############################################################################
library(raster)
library(Cairo)
library(rasterVis)
# create RasterLayer / Stack
r <- raster(nrows=10, ncols=10)
r <- setValues(r, 1:ncell(r))
s <- stack(r,r*2)
# single plot is done
CairoPNG(width = 400, height = 400, filename="test.png")
levelplot(s)
dev.off()
# plot in a loop: no plots are done!
for(i in 1:3){
print(paste("Cairo loop",i))
levelplot(s*i)
}
# plot in a loop with cairo: plots are black
for(i in 1:3){
print(paste("Cairo loop",i))
CairoPNG(width = 400, height = 400, filename="test.png")
levelplot(s*i)
dev.off()
}
[[alternative HTML version deleted]]