ggplot2: add ordered category labels to stacked bar chart

前端 未结 3 867
春和景丽
春和景丽 2021-01-26 09:55

I\'m trying to make a stacked bar chart of microbiome abundance (dataset at the end). Since there are a lot of classes, it\'s hard to tell the difference between colors, so I wa

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-26 10:35

    Does this work?

    ggplot(abun, aes(x = status, y = freq, fill = Order, label = Order)) +
      geom_bar(stat = "identity", col = "black") +
      ylab("Frequency (%)") +
      geom_text(position = position_stack(vjust = 0.5)) +
      theme(text = element_text(size = 20, face = "bold"), legend.text = element_text(size = 12, face = "plain"))
    

提交回复
热议问题