Export a graph to .eps file with R

点点圈 提交于 2019-11-26 12:18:12

问题


How do I export a graph to an .eps format file? I typically export my graphs to a .pdf file (using the \'pdf\' function), and it works quite well. However, now I have to export to .eps files.


回答1:


The easiest way I've found to create postscripts is the following, using the setEPS() command:

setEPS()
postscript("whatever.eps")
plot(rnorm(100), main="Hey Some Data")
dev.off()



回答2:


If you are using ggplot2 to generate a figure, then a ggsave(file="name.eps") will also work.




回答3:


The postscript() device allows creation of EPS, but only if you change some of the default values. Read ?postscript for the details.

Here is an example:

postscript("foo.eps", horizontal = FALSE, onefile = FALSE, paper = "special")
plot(1:10)
dev.off()



回答4:


Another way is to use Cairographics-based SVG, PDF and PostScript Graphics Devices. This way you don't need to setEPS()

cairo_ps("image.eps")
plot(1, 10)
dev.off()



回答5:


Yes, open a postscript() device with a filename ending in .eps, do your plot(s) and call dev.off().



来源:https://stackoverflow.com/questions/5142842/export-a-graph-to-eps-file-with-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!