我一直试图让R在我的plot的百分比标签中打印,
而不是.
,但它不适用于迄今为止我发现的任何方法。我怀疑运行
format(data, decimal.mark=",")
或options(OutDec= ",")
可能不起作用,因为我要求从label=scales::percent(Prozent/100)
打印百分比。我尝试过使用某种paste(Prozent+"%")
作为解决方案,但要点仍然存在。(
plot <- ggplot(probleme, aes(x=reorder(Name, Häufigkeit), y= Häufigkeit, fill = mean)) +
geom_col(position="dodge") +
coord_flip() +
scale_fill_gradient(low = "#FEDFE8", high = "#AC0634", limits=c(6,8), breaks = c(6,7,8))+
scale_y_continuous(limits = c(0,1650), expand = c(0,0.1))+
scale_x_discrete(expand = c(0,0)) +
geom_text(aes(label=scales::percent(Prozent/100)),
position = position_dodge(0.5), hjust = -0.02, colour = "black", size=5)
我可以在代码的哪个地方指定我想要一个小数逗号?任何帮助都会很感激:)谢谢
将decimal.mark = ","
添加到geom_text()
命令中以修改逗号符号。
geom_text(aes(label=scales::percent(Prozent/100,decimal.mark = ",")),
position = position_dodge(0.5), hjust = -0.02, colour = "black", size=5)