-2

我在 Windows 中使用 RScript,默认情况下它将图保存到 pdf 文件Rplots.pdf中,每页一个图。

我想将每个图保存到像 a 这样的图像文件.png中,这可能吗?

4

1 回答 1

3

To save your plots as a png file, the general idea is:

png("spam.png")
plot(...)
dev.off()

similar functions are jpeg and tiff. Wrap all your plots in such calls to png to save the plots to specific names. Adding png() at the top of the script will save all plots in different png files: Rplot001.png, Rplot002.png. I would however try and give meaningful names to the plots.

Using Cairo devices, you can use savePlot. When you plot with ggplot2, the best way imo to save a plot is using ggsave.

于 2012-09-21T07:57:31.633 回答