ggplot2 boxplot [英] ggplot2 boxplot
问题描述
我试图用ggplot2来绘制boxplot。样本数据是这样的。
> s $ p
$ b $
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ 71 mt
95 wt
60 mt
63 mt
75 mt
82 wt
93 wt
87 wt
61 mt
102 wt
60 mt
78 wt
78 wt
87 wt
84 wt
104 wt
81 wt
85 mt
> qplot(factor(genotype),count,data = sampe,geom =boxplot)
命令产生这样的情节:
这里有什么问题?为什么它这样阴谋?
ggplot(sampe,aes(x = factor(genotype),y = count)) + geom_boxplot()
好的,我会回答我自己的问题。按照建议计数值被存储为因子。将它们转换为数字的方法就是这样:
$ b $ pre $ q $ qplot(因子(基因型),as.numeric(count),data = sampe,geom =boxplot)
谢谢大家的建议。
I am trying to plot boxplot using ggplot2. sample data is like this.
> sampe
count genotype
71 mt
50 mt
71 mt
95 wt
60 mt
63 mt
75 mt
82 wt
93 wt
87 wt
61 mt
102 wt
60 mt
78 wt
78 wt
87 wt
84 wt
104 wt
81 wt
85 mt
> qplot(factor(genotype),count,data=sampe,geom="boxplot")
The above command produces plot like this:
what's wrong here?? why is it plotting like this?? Even this below code produces same output.
ggplot(sampe,aes(x=factor(genotype),y=count))+geom_boxplot()
Ok.. I 'll answer my own question. As per the suggestion count values were stored as factor. Converting them to numeric did the trick
qplot(factor(genotype),as.numeric(count),data=sampe,geom="boxplot")
Thank you all for the suggestions.
这篇关于ggplot2 boxplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!