且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在geom_bar ggplot2中重新排列条形图

更新时间:2023-11-26 13:23:52

您的代码工作正常,但barplot从低到高排序。如果您想将酒吧从高到低排序,您必须在之前添加 - 标记:

Your code works fine, except that the barplot is ordered from low to high. When you want to order the bars from high to low, you will have to add a -sign before value:

ggplot(corr.m, aes(x = reorder(miRNA, -value), y = value, fill = variable)) + 
  geom_bar(stat = "identity")

给出: