I posted here about what I'm trying to achieve Sankey bar graphs in R
I've decided to try and implement this in ggplot, but my current issue is this: Given the code below, how would you go about computing the curves df directly from the main df? Is it possible to extract the centres of the stacked geom_bar elements from the plot itself?
df <- data_frame(a=factor(c(1,2,1,2)), b=factor(c(3,3,4,4)), y = c(20,22,24,18))
p <- df %>%
ggplot(aes(x=a, y=y, group=b, fill=b, width=.3)) +
geom_bar(stat="identity", alpha=.9)
p
curves = data_frame(x=c(1,1), xend=c(2,2),
y=c(10, 35), yend=c(30,30),
weight=c(40,40),
width=c(10,40),
b=NA)
p +
geom_curve(data=curves,
aes(x=x, y=y, xend=xend, yend=yend, size=weight),
curvature=.2, alpha=.4)