transition_states() turns a plot into a keyframe animation: the plot is
compiled once per level of states (a "keyframe"), and animate() tweens the
frames between successive keyframes. The scales are trained once over all
states and frozen, so axis breaks, colour ramps and sizes stay put across the
whole animation (the interpolation is non-reactive: the states are fixed at
author time, nothing retrains in response to anything).
Arguments
Value
The modified PlotSpec.
Details
The step only records the intent; call animate() to build the animation and
anim_save() to write it. A plain (non-animated) render ignores it.
Examples
if (requireNamespace("gapminder", quietly = TRUE)) {
library(gapminder)
p <- vplot(gapminder) |>
mark_point(x = gdpPercap, y = lifeExp, size = pop, color = continent) |>
scale_x_continuous(trans = "log10") |>
transition_states(year)
}
