saving plots to pdf fails

前端 未结 2 2104
星月不相逢
星月不相逢 2021-01-26 13:45

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 i

相关标签:
2条回答
  • 2021-01-26 14:02

    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 )

    0 讨论(0)
  • 2021-01-26 14:09

    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 讨论(0)
提交回复
热议问题