开发者

Export a graph to .eps file with R

开发者 https://www.devze.com 2023-02-13 17:40 出处:网络
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

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.


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()


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


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()


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()


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

0

精彩评论

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

关注公众号