| stat_hist | R Documentation |
The output of geom_histogram() is mostly different from what produced by hist().
The geom_hist() is designed to use mid point breaks and counts calculated by hist,
and thus produce identical figure with hist().
stat_hist(
mapping = NULL,
data = NULL,
geom = "bar",
position = "identity",
breaks = "Sturges",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_hist(
mapping = NULL,
data = NULL,
stat = "hist",
position = "identity",
breaks = "Sturges",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom, stat |
Override the default connection between |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
breaks |
the number of cells or an algorithm to compute it, see also |
... |
Other arguments passed on to
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
ggplot layer
set.seed(42)
x <- rnorm(100)
dd = data.frame(x = c(x, x+2), type=rep(LETTERS[1:2], each=100))
require(ggplot2)
ggplot(dd, aes(x)) + geom_hist(breaks=15, color="steelblue") +
geom_text(stat="hist", breaks=10, vjust=-1, size=5)
ggplot(dd, aes(x)) + geom_hist(breaks=15, aes(fill=type), position='dodge')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.