| mark_histogram | R Documentation |
Counts how many rows fall into each bin of a numeric x
variable and draws one bar per bin. Bins are closed on the right, like
graphics::hist(), and the lowest bin also includes its left edge.
Mapping color stacks one bar segment per colour within each bin.
With neither bins nor binwidth, the number of bins follows Sturges'
rule and the edges are rounded to tidy values, as in
graphics::hist(). All facet panels share the same bins.
The counts are computed in R when the plot is compiled. Rows with a
missing x are dropped first, with a warning.
mark_histogram(
spec,
...,
data = NULL,
style = list(),
bins = NULL,
binwidth = NULL
)
spec |
A glyph_spec |
... |
Aesthetic mappings: |
data |
Optional per-mark data override |
style |
Named list of fixed visual properties |
bins |
Number of equal-width bins spanning the range of |
binwidth |
Width of each bin. Bin edges are multiples of |
Modified glyph_spec object with the histogram mark added
glyph(mtcars, x = mpg) |>
mark_histogram(binwidth = 2.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.