【问题标题】:Color histogram bars using stat_bin ggplot使用 stat_bin ggplot 的颜色直方图条
【发布时间】:2021-08-28 05:52:40
【问题描述】:

我想更改直方图条的填充和颜色,但是当前的方法不起作用, 我正在使用以下填充和颜色:

ggplot(dfAllCounts, aes(x=months)) +
  stat_bin(binwidth=6, geom="text", aes(label=after_stat(count)), vjust=-1, fill="#d2aa47", color = '#163B8B')

但是,实际的情节没有正确显示:

【问题讨论】:

    标签: r ggplot2 statistics r-markdown histogram


    【解决方案1】:

    完成! 修复了这个:

    br <- seq(0, 178, 10)
    ggplot(dfAllCounts, aes(x=months)) +
      stat_bin(binwidth=6, fill="#d2aa47", color = '#163B8B', size = .8, alpha = 0.3) +
      stat_bin(binwidth=6, geom="text", aes(label=..count..), vjust=-1) +
      ylim(c(0, 175)) + 
      scale_x_continuous(breaks = br)```
    

    【讨论】:

      猜你喜欢
      • 2019-08-22
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多