开发者

saving plots to pdf fails

When I use pdf("somefile.pdf") to save my plots to a pdf file, everything seems to work. No error messages or whatsoever. Still the result is screwed (file size is NOT 0 KB) but I can't open it using preview nor adobe reader. I am running Mac OS 10.6开发者_如何学JAVA and the latest R Studio release. Any suggestions? Note png()works perfectly fine, so does sweave and pdf plots from ggplot.


Did you remember to close the file via dev.off() before trying to view it?

(See also: problem saving pdf file in R with ggplot2 )


The pdf and png devices work a little different. The pdf device by default will put multiple plots into a single file, so it will not finalize the file until you tell it that you are finished creating the plots (with dev.off). The png device will put 1 plot in 1 file, so will create multiple files for multiple plots. So as soon as you start a second plot, the 1st file will be finalized and can be opened and used. You still need dev.off to finalize the last file after the last plot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜