I am trying to figure out diverging stacked bar charts made in ggplot. I followed an example posted here. Everything works out, except the order of the stacked bars on the
You need to fix the order of your fill variable (color) by adding these two lines (before ggplot):
color
ggplot
my.lows$color <- factor(my.lows$color, levels = my.colors, ordered = TRUE) my.highs$color <- factor(my.highs$color, levels = rev(my.colors), ordered = TRUE)
Then the plot looks like this: