scale_x_manual | R Documentation |
scale_x_manual()
and scale_y_manual()
are hybrid discrete and continuous
position scales for the x
and y
aesthetics. These accept input like
discrete scales, but may map these discrete
values to continuous values that needn't be equally spaced.
scale_x_manual(values, c_limits = NULL, position = "bottom", ...)
scale_y_manual(values, c_limits = NULL, position = "left", ...)
values |
A |
c_limits |
Either |
position |
For position scales, The position of the axis.
|
... |
Arguments passed on to
|
Many thanks to Constantin Ahlmann-Eltze for discussion and suggesting the adoption of this functionality in ggh4x.
A <ScaleManualPosition>
object that can be added to a plot.
There currently is a known bug wherein a c_limits
cannot be applied
correctly when that range is within the range of the discrete limits.
sep_discrete()
# A boxplot with interactions
p <- ggplot(mpg, aes(interaction(year, cyl), displ)) +
geom_boxplot()
# Manually setting positions
p + scale_x_manual(values = c(1, 2, 4, 6, 7, 9, 10))
# Using a function to separate grouped labels
p + scale_x_manual(values = sep_discrete())
# Expanding the continuous limits
p + scale_x_manual(values = sep_discrete(), c_limits = c(NA, 15))
# Together with grouped axis
p + scale_x_manual(values = sep_discrete(), guide = guide_axis_nested())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.