ease_aes() chooses the easing function that shapes how the interpolation
fraction moves through each transition — e.g. "cubic-in-out" starts and ends
gently. By default it applies to every interpolated aesthetic; the
position/color/size/alpha arguments override it for one class each, so
marks can glide into place on a cubic curve while their colour crossfades
evenly.
Usage
ease_aes(
plot,
ease = "linear",
position = NULL,
color = NULL,
size = NULL,
alpha = NULL,
colour = NULL
)Arguments
- plot
A PlotSpec carrying a
transition_states().- ease
An easing name:
"linear", or a family (quad/cubic/quart/quint/sine/expo/circ/back/elastic/bounce) with a direction suffix (-in,-out,-in-out), e.g."cubic-in-out". Used for any class not given its own easing below.- position, color, size, alpha
Optional per-class easings, named the same way as
ease.NULL(the default) means "useease". Each covers one class of drawn property:position— x and y, and every other coordinate-space quantity (bar widths, angles, path vertices, text rotation). It also decides when discrete attributes flip, since those snap at the halfway point.color—colorandfill, including per-element fills.size—size,linewidth, and radii.alpha— opacity, and the fade of marks entering or leaving a state.
positioncovers x and y together: the engine has a single positional curve, so the two axes cannot be eased apart.- colour
An alias for
color; supplying both is an error.
Value
The modified PlotSpec.
Examples
# Four bars in every state, so each bar tweens into its next height.
d <- data.frame(t = rep(1:3, each = 4), g = rep(letters[1:4], 3),
v = c(1, 3, 2, 4, 4, 1, 3, 2, 2, 4, 1, 3))
vplot(d) |>
mark_bar(x = g, y = v, fill = g) |>
transition_states(t) |>
ease_aes("cubic-in-out")
# Bars settle into place gently, but the colour crossfade stays even.
vplot(d) |>
mark_bar(x = g, y = v, fill = v) |>
transition_states(t) |>
ease_aes("cubic-in-out", color = "linear")
