I am trying to embed a .eps file for a journal publication requirements.
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)
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()
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.
In order to do that I used:
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:
Error in embedFonts(file = "Figure5.eps", outfile = "Figure5EMB.eps", : GhostScript was not found
I have GhostScript 9.18 installed in the following path: C:\Program Files (x86)\gs\gs9.18
Any suggestions?
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 ?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With