2015-10-06 53 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顯示設備儘管更粗暴地工作)。