【发布时间】:2019-10-22 21:11:38
【问题描述】:
我想用geom_text() 创建一个条形图。每个条形图上方应该是变量的计数。但在这种情况下,文本的位置在条形图的中间。
有人可以帮我解决这个问题吗?
new.data <- diamonds[ which( diamonds$clarity =="VS1" | diamonds$clarity =="VS2") , ]
ggplot(data=new.data, aes(x=clarity, fill=cut)) +
geom_bar(position = "dodge",stat = "count") +
geom_text(stat='count', aes(label=..count..), vjust=-1)
【问题讨论】:
-
添加
position = position_dodge(width = 1)