无法更改ggplot/geom_text中的字体

问题描述:

我无法在geom_text中设置字体.这是我尝试过的:

I can't set my fonts in geom_text. Here is what I tried:

    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

我已经按照指示导入了所有字体.这里.有什么想法出了什么问题吗?

I already imported all fonts as indicated here. Any ideas what is still going wrong?

我会尝试"

windowsFonts(Times=windowsFont("TT Times New Roman"))

在执行此操作时,您明确指定Windows字体映射.

In doing this your specifying explicitly the Windows Font mapping.