Putting Labels Above Bars in Barplots in R
Let’s say you are creating a barplot in R. Sometimes you want to label the bars below the X axis. But sometimes you might also want to put a label above the bars. This is pretty easy to do but a little hidden. Below is a working example based on randomly generated data that illustrates how to do this. You can play around with the configuration parameters as much as you want, but this gives you the general idea.
x = rbind(abs(rnorm(5)))
barX <- barplot(x, ylim=c(0, max(x)+0.5), names.arg=c(1,2,3,4,5))
text(x=barX, y=x+0.07, label=c("a", "b", "c", "d", "e"))