View source: R/gizmo-histogram.R
gizmo_histogram | R Documentation |
This guide displays a histogram of the aesthetic. If the aesthetic is
colour
or fill
, the shape will reflect this.
gizmo_histogram(
key = waiver(),
hist = NULL,
hist.args = list(),
hist.fun = graphics::hist,
just = 1,
oob = oob_keep,
metric = "counts",
alpha = NA,
theme = NULL,
position = waiver(),
direction = NULL
)
key |
A sequence key or binned key specification. Internally defaults to a sequence key when the scale is continuous and a binned key when the scale is binned. |
hist |
One of the following:
|
hist.args |
A |
hist.fun |
A |
just |
A |
oob |
An out-of-bounds handling function that affects the cap colour. Can be one of the following:
|
metric |
A |
alpha |
A |
theme |
A |
position |
A |
direction |
A |
Non-finite values such as NA
and NaN
are ignored while infinite values
such as -Inf
and Inf
are squished to the limits.
A <GizmoHistogram>
object.
Other gizmos:
gizmo_barcap()
,
gizmo_density()
,
gizmo_grob()
,
gizmo_stepcap()
# A standard plot
p <- ggplot(mpg, aes(displ, hwy, colour = cty)) +
geom_point() +
scale_colour_viridis_c()
# Histogram from plot data
p + guides(colour = gizmo_histogram())
# Using bins instead of gradient
p + guides(colour = gizmo_histogram("bins"))
# Providing custom values to compute histogram
p + guides(colour = gizmo_histogram(hist = runif(1000, min = 5, max = 35)))
# Providing precomputed histogram
p + guides(colour = gizmo_histogram(hist = hist(mpg$cty, breaks = 10)))
# Alternatively, parameters may be passed through hist.args
p + guides(colour = gizmo_histogram(hist.arg = list(breaks = 10)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.