R Mac上的错误:";家庭';新罗马时代';不包括在postscript()设备中;
我正在macbook上使用R 此代码:R Mac上的错误:";家庭';新罗马时代';不包括在postscript()设备中;,r,macos,fonts,ggplot2,postscript,R,Macos,Fonts,Ggplot2,Postscript,我正在macbook上使用R 此代码: postscript("plot.eps") ggplot(SomeData, aes (x=Cue, y=var1, group=var2, color=var2, shape=var2)) + geom_line(size=0.5) + geom_point(size = 3) + geom_errorbar(aes(ymin=Var1-ci, ymax=Var1+ci), width=0.15, size=0.5) + xla
postscript("plot.eps")
ggplot(SomeData, aes (x=Cue, y=var1, group=var2, color=var2, shape=var2)) +
geom_line(size=0.5) +
geom_point(size = 3) +
geom_errorbar(aes(ymin=Var1-ci, ymax=Var1+ci), width=0.15, size=0.5) +
xlab("Var1") + ylab("Var2")+
coord_cartesian(ylim=c(600, 675)) +
theme(axis.text = element_text(colour = "black")) +
scale_colour_manual(values=darkcols) +
theme(text = element_text(size=16, family="Times New Roman")) +
theme(legend.position="bottom")
dev.off()
返回此错误:
Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
family 'Times New Roman' not included in postscript() device
字体族是在绘图上定义的。尝试用postscript(family=“Times”)
和postscript(family=“Times New Roman”)
定义它,但没有成功
尝试了font\u import()
/loadfonts()
,但这样做会产生更多错误(执行此操作后,绘图甚至不会显示在QUARTZ上)
选中字体文件夹中禁用的字体,启用Times New Roman
用名称(postscriptFonts())
检查了R中可用的字体,它就在那里
正如我所说,plot在Quartz中看起来非常完美,但将其保存为带有postscript的.eps会生成上述错误和一个空白文件
关于如何解决这个问题有什么想法吗?这似乎是可行的(有时)。因此,我认为您只需要将family=“Times”添加到postscript()函数中
p <- ggplot(mtcars, aes (x=cyl, y=disp)) +
geom_point(size = 3) +
theme(text = element_text(size=16, family="Times")) +
theme(legend.position="bottom")
postscript("plot.eps", family="Times")
p
dev.off()
p您也可以尝试使用Cairo
软件包,根据我的经验,该软件包在使用不同字体时效果更好
library(Cairo)
cairo_ps("test.eps", family = "Times")
plot(rnorm(100))
dev.off()