【问题标题】:How can I specify the bin width for just one histogram?如何为一个直方图指定 bin 宽度?
【发布时间】:2016-09-15 10:34:35
【问题描述】:

如何为一个直方图指定 bin 宽度?

library(GGally)
data(tips, package="reshape")

library(ggplot2)
ggpairs(data=tips, # data.frame with variables
        columns=1:3, # columns to plot, default to all.
        title="tips data", # title of the plot
        mapping=aes(color=sex)) # aesthetics, ggplot2 style

【问题讨论】:

  • 最简单的方法是改变ggmatrix。即gg <- ggpairs(...,然后是gg[3,1] <- gg[3,1] + geom_histogram( binwidth = 50) ; gg
  • 如果您只想在一个方面进行更改,请按照stackoverflow.com/questions/17271968/… 的行覆盖该单元格

标签: r histogram ggally


【解决方案1】:

作为@user2957945 mentioned:

library(GGally)
data(tips, package="reshape")

library(ggplot2)
gg <- ggpairs(data=tips, # data.frame with variables
        columns=1:3, # columns to plot, default to all.
        title="tips data", # title of the plot
        mapping=aes(color=sex)) # aesthetics, ggplot2 style
gg[3,1] <- gg[3,1] + geom_histogram( binwidth = 50)
gg

【讨论】:

    猜你喜欢
    • 2020-10-23
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 2016-04-26
    • 2017-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多