View source: R/guide-colsteps.R
| guide_colsteps | R Documentation |
Similar to guide_coloursteps(), this guide
displays continuous colour or fill aesthetics. It has additional options
to display caps at the end of the bar, depending on out-of-bounds values.
guide_colsteps(
title = waiver(),
key = "bins",
first_guide = "axis_base",
second_guide = "axis_base",
shape = "triangle",
size = NULL,
show = NA,
alpha = NA,
reverse = FALSE,
suppress_labels = "second",
oob = scales::oob_keep,
theme = NULL,
position = waiver(),
vanilla = TRUE,
available_aes = c("colour", "fill")
)
title |
A |
key |
A bins key specificiation. Defaults to
|
first_guide, second_guide |
Guides to flank the colour steps. Each guide can be specified using one of the following:
The |
shape |
A cap specification by providing one of the following:
|
size |
A |
show |
A |
alpha |
A |
reverse |
A |
suppress_labels |
A |
oob |
An out-of-bounds handling function that affects the cap colour. Can be one of the following:
|
theme |
A |
position |
A |
vanilla |
A |
available_aes |
A |
As steps are rendered as clipped rectangles, it is important to use a
graphics device that can render clipped paths. This can be checked by using
check_device("clippingPaths").
A <Guide> object
Other standalone guides:
guide_axis_base(),
guide_axis_dendro(),
guide_axis_nested(),
guide_circles(),
guide_colbar(),
guide_colring(),
guide_legend_base(),
guide_legend_cross(),
guide_legend_group()
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point(aes(colour = cty))
# The colour steps show caps when values are out-of-bounds
p + scale_colour_viridis_b(
limits = c(10, NA),
guide = "colsteps"
)
# It also shows how oob values are handled
p + scale_colour_viridis_b(
limits = c(10, 30), oob = scales::oob_censor,
guide = "colsteps"
)
# Adjusting the type of cap
p + scale_colour_viridis_b(
limits = c(10, 30),
guide = guide_colsteps(shape = "round")
)
# The default is to use the breaks as-is
p + scale_colour_viridis_b(
limits = c(10, 30), breaks = c(10, 20, 25),
guide = "colsteps"
)
# But the display can be set to use evenly spaced steps
p + scale_colour_viridis_b(
limits = c(10, 30), breaks = c(10, 20, 25),
guide = guide_colsteps(key = key_bins(even.steps = TRUE))
)
# Using tick marks by swapping side guides
p + scale_colour_viridis_b(
guide = guide_colsteps(
first_guide = "axis_base",
second_guide = "axis_base"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.