【问题标题】:R: Removing negative log scale from geom_histogram graphR:从 geom_histogram 图中删除负对数刻度
【发布时间】:2018-04-10 01:24:30
【问题描述】:

我正在使用 geom_histogram 绘制直方图:

ggplot(middle_single, aes(clustersize)) + geom_histogram(binwidth = 100, drop=TRUE)   +scale_y_log10(limits=c(0.1,100)) 

但它显示计数为零的箱的负值(0 的日志是负 inf),但我想从我的图表中删除它们。我怎样才能做到这一点?

我在网上查了很多问题,但没有一个能真正解决我的问题(Histogram with "negative" logarithmic scale in RHow to suppress zeroes when using geom_histogram with scale_y_log10

【问题讨论】:

  • 您使用的是哪个版本的ggplot2?我无法在 2.2.1 中复制向下的条

标签: r ggplot2 histogram


【解决方案1】:

我可以在 Ganesh Shastry 对另一个问题的回复中找到一个解决方案:https://stackoverflow.com/a/63522382/4563445。使用以下内容:

scale_y_log10(oob = scales::squish_infinite) +

警告信息依然存在,但剧情已修复!

【讨论】:

    【解决方案2】:

    也许从您的数据中删除它们?

    trimmed_data <- middle_single[middle_single$clustersize >=0,]
    

    然后剧情?

    【讨论】:

      猜你喜欢
      • 2013-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-30
      • 2021-11-11
      • 1970-01-01
      • 2020-01-03
      • 1970-01-01
      相关资源
      最近更新 更多