可以在ggplot命令中使用reorder函数对柱状图的成分进行排序。以下是修改后的代码:

ggplot(data=io,aes(x=reorder(modu, -abundance),y=abundance,fill=taxa))+
  geom_bar(position = 'fill',stat = 'identity',width = 0.7)+
  labs(y='Abundance',x='Module',color='Taxa')+
  theme(axis.text=element_text(colour='black',size=9))

其中,reorder函数中的参数-abundance表示按照abundance的大小降序排列。

ggplot 柱状图排序:如何按成分大小排列

原文地址: https://www.cveoy.top/t/topic/nlc8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录