'gganimate: change state_length in transition_manual

I have this dummy data as example:

library(ggplot2)
library(gganimate)

dummy <- data.frame(year = 2000:2022,
                    inside = rnorm(23),
                    x = 1, y = 1)

ggplot() +
  geom_point(data = dummy,
             aes(x = x, y = y,
                 col = inside)) +
  transition_manual(year) +
  labs(title = "{current_frame}")

And I got:

Example gif

What I'd like is to make the frames stay longer on the screen. Is there a way to do so when using transition_manual?

Thanks!

NB: This is a just a example for which transition_states would perfectly work (with state_length argument), but I have to use transition_manual for my real application.



Solution 1:[1]

You can adapt the number of frames to slow down the speed:

panim <- ggplot() +
  geom_point(data = dummy, aes(x = x, y = y, col = inside)) +
  transition_manual(year) +
  labs(title = "{current_frame}")
# Slow
animate(panim, nframes = 1000)
# Fast
animate(panim, nframes = 10)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hyman