[英]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.