gizmo_histogram {legendry} | R Documentation |
Guide gizmo: histogram
Description
This guide displays a histogram of the aesthetic. If the aesthetic is
colour
or fill
, the shape will reflect this.
Usage
gizmo_histogram(
key = "sequence",
hist = NULL,
hist.args = list(),
hist.fun = graphics::hist,
just = 1,
oob = oob_keep,
alpha = NA,
theme = NULL,
position = waiver(),
direction = NULL
)
Arguments
key |
A sequence key or binned key specification. |
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:
|
alpha |
A |
theme |
A |
position |
A |
direction |
A |
Details
Non-finite values such as NA
and NaN
are ignored while infinite values
such as -Inf
and Inf
are squished to the limits.
Value
A <GizmoHistogram>
object.
See Also
Other gizmos:
gizmo_barcap()
,
gizmo_density()
,
gizmo_grob()
,
gizmo_stepcap()
Examples
# 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)))