| animate | R Documentation |
Add animation/transition behavior
animate(
spec,
transition = "morph",
duration = 500,
stagger = 0,
by = NULL,
easing = "ease-in-out",
loop = FALSE
)
spec |
A glyph_spec |
transition |
Transition type: "morph", "fade", "slide", "none" |
duration |
Duration in milliseconds |
stagger |
Delay between successive marks in ms (for entrance effects) |
by |
Column that defines animation keyframes. The plot shows one
value of it at a time and moves between them, e.g. |
easing |
Easing function: "linear", "ease-in", "ease-out", "ease-in-out", "bounce", "elastic" |
loop |
Repeat animation (TRUE, FALSE, or number of times) |
Modified glyph_spec
# Entrance animation: bars grow from baseline
glyph(mtcars, x = cyl, y = mpg) |>
mark_bar() |>
animate(transition = "slide", stagger = 50)
# Keyframe animation: morph between groups
glyph(mtcars, x = wt, y = mpg) |>
mark_point(size = hp, color = cyl) |>
animate(by = gear, transition = "morph", duration = 800)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.