stat_bin(mapping = NULL, data = NULL, geom = "bar", position = "stack",
width = 0.9, drop = FALSE, right = FALSE, binwidth = NULL,
origin = NULL, breaks = NULL, ...)
aes
or aes_string
. Only needs to be set
at the layer level if you are overriding the plot defaults.TRUE
, right-closed, left-open, if FALSE
,
the default, right-open, left-closed.m <- ggplot(movies, aes(x=rating)) m + stat_bin() m + stat_bin(binwidth=0.1) m + stat_bin(breaks=seq(4,6, by=0.1)) # See geom_histogram for more histogram examples
# To create a unit area histogram, use aes(y = ..density..) (linehist <- m + stat_bin(aes(y = ..density..), binwidth=0.1, geom="line", position="identity")) linehist + stat_density(colour="blue", fill=NA)
# Also works with categorical variables ggplot(movies, aes(x=mpaa)) + stat_bin() qplot(mpaa, data=movies, stat="bin")