ggsave png error with larger size
NOTE : Using R 2.12.1 on Windows 7 64bit, this problem has vanished. If you run into this problem, first try updating your R version.
After the problem came up again in another question, I reran my test code on my new system to see if the bug was gone, and it is.
EDIT: The trick why underlying code could work is the fact that it uses a resolution of only 72 dpi and not 300dpi as is the standard in ggsave()
I believe.
so ggsave("tst.png",height=9,width=12,dpi=72)
could do the trick.
But you really must have a crazy plot if it can't take it. As far as I can guess, the problem is related to the graphics card (as derived from this message from prof. Ripley ).
If resolution is a problem, you could better go to vectorized formats like eps or pdf.
EDIT 2 :
Apparently, there is a bug somewhere involving some kind of memory leak maybe? Give following code:
library(car)
library(ggplot2)
qplot(education,data=Vocab,geom="density",colour=sex)+facet_wrap(~year)
setwd("G:/Temp")
i<-1
while(1){
tryCatch(ggsave("tst.png",height=9+i,width=12+i),error=function(e) {print(i);stop(e);})
i <- i+1
}
This runs fine for me until i reaches about 9, then I get the error you get. Every next attempt at running the code, starting again with i=1
, gives the same error. Trying with png()
and dev.off()
gives again the same error. Seems like there is some part of a memory filling up and not being emptied, effectively preventing to get another png file saved. also for me gc()
didn't do a thing. Even closing R and reopening again didn't work.
It is "solved" using ggsave("tst.pdf")
, but the bug remains. I'd report to the R team.