Skip to contents

animate() compiles a plot carrying a transition_states() into one keyframe scene per state, training the scales once over all states and freezing them, and returns a vellum_animation. Write it with anim_save(); printing it shows the first keyframe as a preview.

Usage

animate(plot, nframes = 50, fps = 25)

Arguments

plot

A PlotSpec with a transition_states() (and optionally an ease_aes()).

nframes

Total number of frames to render.

fps

Frames per second (the playback rate written into the file).

Value

A vellum_animation.

Details

Per-state statistics (e.g. a smooth) are recomputed per keyframe, but no scale domain retrains — the frozen scales are the observable proof the animation stayed non-reactive (axis breaks do not move between frames).

Examples

if (FALSE) { # \dontrun{
vplot(mtcars) |>
  mark_point(x = wt, y = mpg) |>
  transition_states(cyl) |>
  animate(nframes = 50, fps = 25)
} # }