I have following code
d <- data.frame(a = c("a", "b", "a", "b"), b = c("c", "c", "d", "d"), y = c(4, 5, 3, 2))
ggplot(data = d, aes(x = a, y = y, fill = b)) +
geom_col(position = position_dodge(0.9)) +
annotate("segment", x = "a", xend = "a", y = 5, yend = 4, arrow = arrow())
What I'm getting is following:
What I want is to have an arrow point to a concrete bar. And potentially I want to have multiple arrows. For example like this:
The problem is that I don't know how to address concrete bar on the x-axis, i.e. which are the x-values for individual dodged bars.