2015-10-06 52 views
4

我想为期刊发布要求嵌入一个.eps文件。R不识别GhostScript来嵌入eps图

我使用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

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。

为了做到这一点我用:

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

这些功能都失败了,给了我以下错误:

错误的embedFonts(文件= “Figure5.eps”,OUTFILE =“ Figure5EMB.eps”: GhostScript的未找到

我有GhostScript的9.18安装在以下路径:C:\ Program Files文件(x86)的\ GS \ gs9.18

有何建议?

回答

1

根据R documentation,您使用R_GSCMD环境变量设置了R将要使用的Ghostscript可执行文件的位置,但未能搜索到PATH。你是否设置了环境变量,或者是否有添加到PATH环境变量中的Ghostscript可执行文件的路径?

还请注意R开发人员邮件列表中的thisthis。我不知道为什么文档认为有不同的可执行文件来查看和操作PostScript/PDF文件,这是不正确的(尽管它可能需要使用不同的应用程序,如GSView来查看Ghostscript显示设备尽管更粗暴地工作)。