I would like to draw lines between different elements in a stacked bar plot using ggplot2. I have plotted a stacked barchart using ggplot2 (first figure), but would like to get something like in second figure.
dta <- tribble(
~colA, ~colB, ~colC,
"A", "a", 1,
"A", "b", 3,
"B", "a", 4,
"B", "b", 2); dta
ggplot(dta, aes(x = colA, y = colC, fill = colB)) +
geom_bar(stat = "identity")
The fastes way would probably to the add the lines by manually drawing them into the exported image. However, I prefere avoiding this.
This Stackoverflow entry (esp. the answere of Henrik) gives a potential solution. However, I was wondering whether there is another solution that is more generic (i.e. that does not require to manually define all the start and end points of the segments/lines)