2014-09-24 47 views
2

我正在繪製具有多個變量的條形圖,但y軸上的值沒有從低到​​高排序。我需要指定嗎?使用多個變量對geom_bar中的y值進行排序

head(data.m) 

     miRNA variable   value 
1 hsa-miR-92a-3p  Ago1 16.1916036788 
2 hsa-miR-99b-5p  Ago1 15.6601825183 
3 hsa-let-7e-5p  Ago1 13.4926162349 
4 hsa-miR-15b-5p  Ago1 11.3220579493 
5 hsa-miR-378i  Ago1 6.0752193103 
6 hsa-miR-222-3p  Ago1 6.6619305684 
ggplot(data.m, aes(variable, value, fill=variable)) + geom_bar(stat="identity") + facet_grid(~miRNA, scales="free_y") 
+1

可能重複http://stackoverflow.com/questions/5208679/order-bars-in- GGPLOT2-條形圖) – hrbrmstr 2014-09-24 10:53:54

回答

1

嘗試:

data.m$miRNA = factor(as.character(data.m$miRNA), levels = data.m$miRNA[order(data.m$value)]) 
ggplot(data.m, aes(miRNA, value, fill=variable)) + geom_bar(stat="identity") 

enter image description here

的[在GGPLOT2條形圖命令吧(
相關問題