View source: R/type_histogram.R
type_histogram | R Documentation |
Type function for histogram plots. type_hist
is an alias for
type_histogram
.
type_histogram(
breaks = "Sturges",
freq = NULL,
right = TRUE,
free.breaks = FALSE,
drop.zeros = TRUE
)
type_hist(
breaks = "Sturges",
freq = NULL,
right = TRUE,
free.breaks = FALSE,
drop.zeros = TRUE
)
breaks |
Passed to
|
freq |
logical; if |
right |
logical; if |
free.breaks |
Logical indicating whether the breakpoints should be
computed separately for each group or facet? Default is |
drop.zeros |
Logical indicating whether bins with zero counts should be
dropped before plotting. Default is |
# "histogram"/"hist" type convenience string(s)
tinyplot(Nile, type = "histogram")
# Use `type_histogram()` to pass extra arguments for customization
tinyplot(Nile, type = type_histogram(breaks = 30))
tinyplot(Nile, type = type_histogram(breaks = 30, freq = FALSE))
# etc.
# Grouped histogram example
tinyplot(
~Petal.Width | Species,
type = "histogram",
data = iris
)
# Faceted version
tinyplot(
~Petal.Width, facet = ~Species,
type = "histogram",
data = iris
)
# For visualizing faceted histograms across varying scales, you may also wish
# to impose free histogram breaks too (i.e., calculate breaks separately for
# each group). Compare:
# free facet scales + shared histogram breaks, versus...
tinyplot(
~Petal.Width, facet = ~Species,
facet.args = list(free = TRUE),
type = type_histogram(),
data = iris
)
# ... free facet scales + free histogram breaks
tinyplot(
~Petal.Width, facet = ~Species,
facet.args = list(free = TRUE),
type = type_histogram(free = TRUE),
data = iris
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.