【问题标题】:stat_bin reverting to defaultstat_bin 恢复为默认值
【发布时间】:2012-08-16 17:36:42
【问题描述】:

我很难让我的直方图绘制正确的 bin 数量。我希望每个 bin 的值都是 1-5、5-10、10-15 等,但是当我使用 stat_bin 时,它会恢复为 range/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.

我在想这可能是一些我在阅读时没有完全掌握的愚蠢语法。 我希望有人能告诉我为什么会这样。

【问题讨论】:

  • 请不要在您的问题中添加答案。我将删除您的答案并将其作为答案发布。

标签: r ggplot2 histogram


【解决方案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)

【讨论】:

  • 谢谢。我没有足够的代表来回答我自己的问题,直到 8 小时后或什么的
  • @user 如果您想在到期后发布自己的答案,请告诉我,我将删除此答案。 (只需在此答案中添加评论,我会收到通知。)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-31
  • 1970-01-01
  • 2015-03-02
  • 2013-11-06
相关资源
最近更新 更多