This is a basic plotting question:
I need to add labels to a clustered/dodged bar chart. I have looked at several examples using text()
, but cannot seem to position the labels correctly.
teachers <- c("A", "B","C", "D", "E")
mean_pre_scores <- c(10, 11, 12, 10,9)
mean_post_scores <- c(12,15,17,13,12)
pre_post <- data.frame(mean_pre_scores, mean_post_scores)
pre_post <- as.matrix(pre_post)
barplot((t(pre_post)), beside = T, names = teachers, legend = c("pre", "post"),
ylim = c(0,20), args.legend = list(x="bottomright"), axes = T, main = "Unit 1 Test",
col=c(26,51))
I want to modify this plot so that the values will be displayed above the bars. It would also be helpful to know how to show the values inside the bars.