Adjust layer params and aesthetics (Layer operation)
Source:R/class-operation-adjust.R
, R/operation-adjust.R
adjust.Rd
A layer operation for adjusting the params and aesthetic mappings of a layer-like object.
Usage
adjust(object, mapping = aes(), ...)
Arguments
- object
One of:
A layer-like object: applies this operation to the layer.
A missing argument: creates an operation
Anything else: creates an operation, passing
object
along to themapping
argument
- mapping
An aesthetic created using
aes()
. Mappings provided here will overwrite mappings inggplot2::layer()
s when this operation is applied to them.- ...
ggplot2::layer()
parameters, such as would be passed to ageom_...()
orstat_...()
call. Params provided here will overwrite params in layers when this operation is applied to them.
Value
A layer-like object (if object
is layer-like) or an operation (if not).
Examples
library(ggplot2)
# Here we use adjust() with nop() ( + 1) to create a copy of
# the stat_smooth layer, putting a white outline around it.
set.seed(1234)
k = 1000
data.frame(
x = seq(1, 10, length.out = k),
y = rnorm(k, seq(1, 2, length.out = k) + c(0, 0.5)),
g = c("a", "b")
) |>
ggplot(aes(x, y, color = g)) +
geom_point() +
stat_smooth(method = lm, formula = y ~ x, linewidth = 1.5, se = FALSE) *
(adjust(aes(group = g), color = "white", linewidth = 4) + 1) +
scale_color_brewer(palette = "Dark2")
# (note this could also be done with copy_under())