Mac 上的 R 错误:"family 'Times New Roman' not included in postscript() device"
R error on a Mac: "family 'Times New Roman' not included in postscript() device"
我在 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) +
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()
returns 这个错误:
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_import()
/ loadfonts()
,但这样做会产生更多错误(执行此操作后 Plot 甚至不会显示在 QUARTZ 上)
检查字体文件夹中禁用的字体,启用Times New Roman。
用 names(postscriptFonts())
检查了 R 中可用的字体,它就在那里。
就像我说的那样,绘图在 Quartz 中看起来很完美,但是将它保存为带有后记的 .eps 会生成上述错误和一个空白文件。
有什么解决办法吗?
这似乎有效(对于 Times)。所以我认为你只需要将 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()
您也可以尝试使用 Cairo
包,根据我的经验,它在不同字体下效果更好。
library(Cairo)
cairo_ps("test.eps", family = "Times")
plot(rnorm(100))
dev.off()
我在 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) +
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()
returns 这个错误:
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_import()
/ loadfonts()
,但这样做会产生更多错误(执行此操作后 Plot 甚至不会显示在 QUARTZ 上)
检查字体文件夹中禁用的字体,启用Times New Roman。
用 names(postscriptFonts())
检查了 R 中可用的字体,它就在那里。
就像我说的那样,绘图在 Quartz 中看起来很完美,但是将它保存为带有后记的 .eps 会生成上述错误和一个空白文件。
有什么解决办法吗?
这似乎有效(对于 Times)。所以我认为你只需要将 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()
您也可以尝试使用 Cairo
包,根据我的经验,它在不同字体下效果更好。
library(Cairo)
cairo_ps("test.eps", family = "Times")
plot(rnorm(100))
dev.off()