R无法识别GhostScript来嵌入eps图形 [英] R does not recognize GhostScript to embed eps plots

查看:75
本文介绍了R无法识别GhostScript来嵌入eps图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图嵌入.eps文件以满足期刊出版要求.

I am trying to embed a .eps file for a journal publication requirements.

我使用ggplot2创建情节:

I create my plot using ggplot2:

p=ggplot(data=sim, aes(x=TIME,y=DV,group=ID))+
  theme_few()+
  geom_point(aes(shape=as.factor(SEASON2)),size=3,fill="white")+
  geom_point(aes(color=as.factor(AGE2),shape=as.factor(SEASON2)),size=3,fill="white",show_guide=F)+
  scale_shape_manual(name="Season",values=c(25,24))+
  geom_line(aes(color=as.factor(AGE2),linetype=as.factor(MODEL2)),size=0.75)+
  scale_linetype_manual(name="Model [Population]",values=c("dotted","solid"))+
  scale_color_manual(name="Age",values=as.vector(c(ggthemes_data$few$medium[5],ggthemes_data$few$medium[4])))+
  theme(legend.position="bottom",legend.direction="vertical",legend.box="horizontal")+
  guides(color=guide_legend(order=1), shape=guide_legend(order=2), linetype=guide_legend(order=3))+
  xlab("Clock time [hours]")+
  ylab("Testosterone levels [ng/dL]")+
  geom_hline(yintercept=300,linetype="dashed",color="black")
print(p)

然后,我生成.eps

And then, I generate the .eps

postscript(file.path(directory,"Script","Figure5.eps"),
           width=10,
           height=12.25,
           paper="a4",
           horizontal=T,
           onefile=TRUE)
print(p)
dev.off()

当我尝试提交绘图时,此.eps未被在线应用程序接受,因为我必须使字体对ADQ Advisor可用.

This .eps was not accepted for the online application when I tried to submit the plot because I have to make the fonts available to ADQ Advisor.

为此,我使用了:

install.packages("extrafont")
library("extrafont")
font_import()
fonts()
loadfonts(device = "postscript") ## for postscript()

embed_fonts("./Figure5.eps", outfile = "./Figure5-embed.eps", options = "-dEPSCrop")

embedFonts(file="Figure5.eps",
          outfile="Figure5EMB.eps",
          options="-dEPSCrop")

这两个函数均失败,并给了我以下错误:

Both of these functions failed and gave me the following error:

embedFonts(file ="Figure5.eps",outfile ="Figure5EMB.eps",错误:找不到GhostScript

Error in embedFonts(file = "Figure5.eps", outfile = "Figure5EMB.eps", : GhostScript was not found

我在以下路径中安装了GhostScript 9.18:C:\ Program Files(x86)\ gs \ gs9.18

I have GhostScript 9.18 installed in the following path: C:\Program Files (x86)\gs\gs9.18

有什么建议吗?

推荐答案

根据R

According to the R documentation you set the location of the Ghostscript executable to be used by R using the R_GSCMD environment variable, failing that the PATH is searched. Do you have that environment variable set or do you have the path to the Ghostscript executable added to the PATH environment variable ?

还请R开发人员邮件列表,以及.我不知道为什么文档认为有不同的可执行文件来查看和操作PostScript/PDF文件,但这不是正确的(尽管您可能希望使用其他应用程序(例如GSView)来查看Ghostscript显示设备的文件效果还好,但粗略得多).

Note also this, from the R developer mailing list, and this. I have no idea why the documentation thinks there are different executables to view and manipulate PostScript/PDF files, this isn't true (though its possible you might want to use a different application, such as GSView, to view files the Ghostscript display device works as well though much more crudely).

这篇关于R无法识别GhostScript来嵌入eps图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆