ggplot strange ordering of stacked bar

前端 未结 3 933
星月不相逢
星月不相逢 2021-01-24 07:44

I am attempting to create a diverging stacked bar like here, and am experiencing a similar issue to this SO question. My approach is slightly different though as I am managing i

3条回答
  •  感动是毒
    2021-01-24 08:12

    Although not intuitive (for me), use:

    ggplot(x, aes(x = 1, y = order(count), fill = response)) +
      geom_col() +
      scale_fill_brewer(palette = "RdBu",direction=1) +
      coord_flip()
    

    It takes into account the ordering based on response (rather than order(response))

提交回复
热议问题