我无法在geom_text中设置字体。这是我试过的:无法在ggplot/geom_text中更改字体
labels_test<-data.frame(a=c("a","b","c"),b=c(1:3),c=c(3:1))
# works
ggplot() + geom_text(data=labels_test,aes(b,c,label=a),color="blue")
# does not work:
ggplot() + geom_text(data=labels_test,aes(b,c,label=a),color="blue",family="Times")
# error message: In grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y,:
# Font family not found in Windows font database
我已经导入了所有的字体,如here所示。任何想法仍然出错?
如果您尝试使用'windowsFonts(Times =“windowFont”(“TT Times New Roman”))'',它会起作用吗? –
是的。谢谢。你应该把它作为答案。你能解释一下吗?当我想使用不同的字体时,我是否必须在所有脚本中执行此操作? – Joschi
我刚刚在Mac上,所以我无法摆弄,但[this](https://groups.google.com/forum/?fromgroups=#!topic/ggplot2/781cT5yMqCg)可能有帮助,但主要是这个想法这是一旦你已经安装了它们给R的字体以明确使用 –