Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R stat_bin恢复为默认值_R_Ggplot2_Histogram - Fatal编程技术网

R stat_bin恢复为默认值

R stat_bin恢复为默认值,r,ggplot2,histogram,R,Ggplot2,Histogram,我有一点困难,让我的直方图绘制正确数量的垃圾箱。我希望每个bin都是值1-5、5-10、10-15等,但当我使用stat_bin时,它会恢复为范围/30默认值 ggplot(tmp,aes(x = values)) + + facet_wrap(~ind) + + geom_histogram(aes(y=..count../sum(..count..)),stat="bin")+ + scale_x_continuous("Percent above 30x")+ +

我有一点困难,让我的直方图绘制正确数量的垃圾箱。我希望每个bin都是值1-5、5-10、10-15等,但当我使用stat_bin时,它会恢复为范围/30默认值

ggplot(tmp,aes(x = values)) + 
+     facet_wrap(~ind) +
+     geom_histogram(aes(y=..count../sum(..count..)),stat="bin")+
+     scale_x_continuous("Percent above 30x")+
+     scale_y_continuous("Fraction of panel")+
+     opts(title = yz)+
+     stat_bin(bandwidth=5.0)
stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
我在想,这可能是我在阅读时没有完全掌握的一些愚蠢的语法。
我希望有人能告诉我为什么会这样

OP发布了此解决方案:将
binwidth=5
参数添加到
geom

ggplot(tmp,aes(x = values)) +
    facet_wrap(~ind) +
    geom_histogram(aes(y=..count../sum(..count..)), binwidth=5)+
    scale_x_continuous("Percent above 30x")+
    scale_y_continuous("Fraction of panel")+
    opts(title = yz)

请不要在问题中添加答案。我将删除你的答案并将其作为答案发布。谢谢。我没有足够的代表回答我自己的问题,直到8小时后或之后something@user如果您想在到期后发布自己的答案,请告诉我,我将删除此答案。(只需在回答中添加注释,我就会得到通知。)