0

I made a bargraph and I want to add values above each bar. How can I do that?

My code is this:

ggplot(NOF.dat.allGCDs2, aes(y=count, x=reorder(variable, -count), fill= reorder(variable, -count)))+
  geom_bar( stat = "identity", color="black")+
    scale_fill_manual(values = pal)+
  theme_bw() +
  labs(x="Global change drivers", y="Count")+
  theme(legend.position = "none") +
  theme(axis.text.x = element_text(angle = 25, hjust=1))

The graph looks like this

I just dot get how to do it.

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
  • 2
    Try adding the line `geom_text(stat = 'count', aes(y = after_stat(count), text = after_stat(count)), nudge_y = 5)` to your plot. – Allan Cameron Dec 01 '22 at 15:11
  • Welcome to Stack Overflow! Please take the [tour] and read through the [help center](http://stackoverflow.com/help), in particular how to [ask]. Your best bet here is to do your research, search for related topics on SO, and give it a go. After doing more research and searching, post a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) of your attempt and say specifically where you're stuck, which can help you get better answers. If you had used Google with the keywords of your question title, you would have found a long URL list with helpful content. – help-info.de Dec 01 '22 at 15:46

0 Answers0