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

时间:2016-09-15 10:34:36

标签: r histogram ggally

如何只为一个直方图指定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

enter image description here

1 个答案:

答案 0 :(得分: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