[英]ggplot2 - geom_text how to position the labels in the middle of the bars
您已经接近了,您只需要更改文本层中的position
参数即可。 以下标准数据集的示例:
library(ggplot2)
ggplot(mpg, aes(class, fill = as.factor(drv))) +
geom_bar() +
geom_text(stat = "count", position = position_stack(vjust = 0.5),
aes(label = after_stat(count)))
由reprex package (v0.3.0) 于 2021 年 2 月 2 日创建
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.