2012-08-16 109 views
2

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

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. 

我在想这可能是一些愚蠢的语法的东西,我没有很好地掌握,而我正在阅读。 我希望有人可以告诉我为什么会发生这种情况。

+0

请不要在您的问题中添加答案。我将删除您的答案并将其作为答案发布。 – Andrie 2012-08-16 17:49:43

回答

1

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) 
+0

谢谢。我没有足够的代表来回答我自己的问题,直到8小时之后或什么 – Stephopolis 2012-08-16 18:14:18

+0

@user如果您想在过期时间后发布自己的答案,请告诉我,我将删除此答案。 (只需在此答案中添加评论,我就会收到通知。) – Andrie 2012-08-16 18:15:54