Declare a position scale to override the trained default. scale_x_continuous()
/ scale_y_continuous() handle numeric (and date/time) axes;
scale_x_discrete() / scale_y_discrete() handle categorical (band) axes and
let you set the level order via limits.
Usage
scale_x_continuous(
plot,
limits = NULL,
trans = "identity",
breaks = NULL,
labels = NULL,
name = NULL
)
scale_y_continuous(
plot,
limits = NULL,
trans = "identity",
breaks = NULL,
labels = NULL,
name = NULL
)
scale_x_discrete(plot, limits = NULL, name = NULL)
scale_y_discrete(plot, limits = NULL, name = NULL)Arguments
- plot
A PlotSpec.
- limits
For continuous scales a numeric length-2 domain
c(min, max); for discrete scales a character vector of levels (sets order / subset).NULLtrains from the data.- trans
Transformation:
"identity"(default),"log10","sqrt","reverse", or ascales::transform_log10()-style transform object.- breaks, labels
Explicit break positions (data units) and their labels, or
NULLto compute them.- name
Axis title, or
NULLto derive from the encoding.
Value
The modified PlotSpec.
Examples
vplot(mtcars) |> mark_point(x = wt, y = mpg) |> scale_x_continuous(limits = c(0, 6))
vplot(mtcars) |> mark_point(x = wt, y = mpg) |> scale_y_continuous(trans = "sqrt")
