Add text on top of a facet dodged barplot using ggplot2

前端 未结 1 1374
鱼传尺愫
鱼传尺愫 2020-12-01 19:34

I\'d like to plot a dodged barplot for two different years and put the revenue numbers on top of the bar accordingly. After trying quite some suggestion I f

相关标签:
1条回答
  • 2020-12-01 19:45

    You need to dodge the text values as well. Try

    qbarplot_yr_1 + geom_text(data = censusData,
             aes(x = County, group=variable, y = value + 150, 
             label = format(value, nsmall = 0, digits=1, scientific = FALSE)), 
             color="blue", position=position_dodge(.9), hjust=.5)
    

    We also need the group= so it knows which values to dodge on.

    0 讨论(0)
提交回复
热议问题