2017-10-10 23 views
-1

[フォントの問題は解決しましたが、問題は文字がSBTのバーにないことです。それは私に2回SBTを与え、私はbarplotためggplotを使用していますが、このエラーを取得しています]図にggplot R、グリッドコールとフォントファミリのエラー

を強調しました。

In grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y, : 
    font family not found in Windows font database​ 

私はextrafontをインストールしようとしましたが、このエラーが発生しました。あなたが最初のextrafontを使用してフォントを登録しようとすることができます

library(ggplot2) 
    plot2 <- ggplot(Test, aes(x=factor(Test$habitat3), y=proportion, fill=proportion)) + 
geom_bar(stat="identity", position="stack", colour="black", fill="grey") + 
geom_errorbar(aes(ymin=stdlow, ymax=stlup, width=0, position="identity")) + 
xlab("Habitat") + 
ylab("root abundance") + 
coord_cartesian(ylim = c(0, 1)) + 
scale_y_continuous(expand=c(0,0)) + 
theme(axis.title.x=element_text(margin = unit(c(6, 0, 0, 0), "mm"))) + 
theme(axis.title.y=element_text(margin = unit(c(0, 6, 0, 0), "mm"))) + 
theme(axis.line.x = element_line(color="black"), axis.line.y = element_line(color="black")) + 
theme(text = element_text(size=14, colour = "black")) + 
theme(legend.position="none") + 
theme(axis.text.y = element_text(size = 14, colour = "black")) + 
theme(axis.text.x = element_text(size = 14, colour = "black")) + 
theme(plot.background=element_blank(), 
panel.grid.major=element_blank(), 
panel.background=element_blank(), 
panel.grid.minor=element_blank(), 
legend.key=element_blank(), 
legend.background=element_blank()) + 
theme(text=element_text(family = "Arial")) + 
annotate("text", x="PV", y=3.1, label="ab") + 
annotate("text", x="WB", y=4.18, label="a") + 
annotate("text", x="AF", y=2.98, label="b") + 
annotate("text", x="EZ", y=3.43, label="ab") 
+0

正確なエラーは何ですか? – sissy

+1

再現可能な例を提供してください –

+0

dput(YOUR_DATA) –

答えて

1

:後R.version 3.4.2 を使用して Imが私のコードです。

library(extrafont) 

font_import() 

loadfonts(device = "postscript") 

次に、あなたがggplot2でそれを使用することができます。

library(ggplot2) 

p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) 

p + geom_text(family = "Arial") 

これが生成します。

enter image description here