ggplot:boxplot排序 [英] ggplot: boxplot sort
本文介绍了ggplot:boxplot排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在ggplot中对箱形图进行排序?
How do I sort a boxplot in ggplot?
这就是我要绘制的内容:
Here's what I'm trying to plot:
qplot( row.names(pcaDF),pcaDF[,1],data=pcaDF,geom="boxplot") + coord_flip()
这是 pcaDF
> str(pcaDF)
'data.frame': 108 obs. of 1 variable:
$ sort(plotdata[, 1], decreasing = F): num -5.89 -5.52 -4.66 -4.54 -3.92 ...
推荐答案
ggplot中的排序由因素的水平决定.要控制因素的排序,请执行以下操作:df中的A:
Sorting in ggplot is regulated by the levels in the factors. To control the sorting of factor: A in df:
df$A = factor(df$A , level = sort(unique(df$A)) )
这篇关于ggplot:boxplot排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文