无法将ggplot另存为eps [英] Cannot save ggplot as eps
本文介绍了无法将ggplot另存为eps的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I've read this and this but cannot make it work.
vDF <- data.frame(v = rnorm(50,1,40))
g <- ggplot(vDF, aes(x = vDF)) + geom_histogram()
ggsave(g, file="name.eps")
我不断收到错误
grDevices :: postscript(...,onefile = FALSE,horizontal = FALSE,:中的错误:无法打开文件'name.eps'
Error in grDevices::postscript(..., onefile = FALSE, horizontal = FALSE, : cannot open file 'name.eps'
为什么我不能做这个工作?我已经看到建议说嘿,就做...
Why can't I make this work? I've see advice saying 'hey just do...
setEPS()
postscript("whatever.eps")
plot(rnorm(100), main="Hey Some Data")
dev.off()
但是我什至无法保存原始的.eps文件.
But I can't even save the original .eps file in the first place.
推荐答案
首先,您的代码中有错误.应该是:
First, there's an error in your code. It should be:
vDF <- data.frame(v = rnorm(50,1,40))
g <- ggplot(vDF, aes(x = v)) + geom_histogram()
(请注意 aes
).
现在,要将图另存为 eps
,您必须在 ggsave
中使用选项 device = eps
:
Now, to save the plot as eps
, you have to use the option device=eps
in ggsave
:
ggsave(g, file="name.eps", device="eps")
这篇关于无法将ggplot另存为eps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文