View source: R/gizmo-stepcap.R
gizmo_stepcap | R Documentation |
This guide displays a binned variant of the colour bar with optional caps at either ends of the bar.
gizmo_stepcap(
key = "bins",
shape = "triangle",
size = NULL,
show = NA,
alpha = NA,
oob = "keep",
theme = NULL,
position = waiver(),
direction = NULL
)
key |
A bins key specificiation. Defaults to
|
shape |
A cap specification by providing one of the following:
|
size |
A |
show |
A |
alpha |
A |
oob |
An out-of-bounds handling function that affects the cap colour. Can be one of the following:
|
theme |
A |
position |
A |
direction |
A |
A GizmoStepcap
object.
Other gizmos:
gizmo_barcap()
,
gizmo_density()
,
gizmo_grob()
,
gizmo_histogram()
# A standard plot
p <- ggplot(mpg, aes(displ, hwy, colour = cty)) +
geom_point()
# Just some recangles
p + scale_colour_viridis_c(guide = gizmo_stepcap())
# Caps show up when there is data outside the limits
p + scale_colour_viridis_c(
limits = c(10, 30),
guide = gizmo_stepcap()
)
# The scale's out-of-bounds handler determines cap colour
p + scale_colour_viridis_c(
limits = c(10, 30), oob = scales::oob_squish,
guide = gizmo_stepcap()
)
# Customising the display of the guide
p +
scale_colour_viridis_c(
oob = scales::oob_squish,
guide = gizmo_stepcap(
shape = "round", show = c(FALSE, TRUE),
size = unit(1, "cm"),
theme = theme(legend.key.height = unit(4, "cm"))
)
) +
theme(
legend.frame = element_rect(colour = "black"),
legend.key.width = unit(0.5, "cm")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.