7

when making animation from ggplot using gganimate, I need to set a lower pace to allow people to read data.

Reading documentation (hard to find options) seems that "nframes" is the proper setting. But I can't slow the animation or set the duration. Any of both approaches would be fine

library("gganimate")
library("tidyverse")

p <- ggplot(airquality, aes(Day, Temp, color = Month)) +
  transition_time(Month) +
  labs(title = 'Month is {frame_time}') +
  geom_path(aes(group = Month), size = 1)

animate(p, nframes = 100)

Error in device(files[i], ...) : unused argument (nframes = 100)
useRj
  • 1,232
  • 1
  • 9
  • 15
  • Do you want the time-series to animate from month-to-month smoothly? I tried setting nframes = 500 and the animation is definitely slower but the frames are static when moving. – Nautica Nov 29 '18 at 17:27
  • I can't reproduce that error. Update your packages and start in a clean session? – Axeman Nov 29 '18 at 20:42
  • I want the animation to take more time to finish, not get a bunch of static frames – useRj Nov 30 '18 at 07:53
  • Use the `fps` argument in your `animate()` call: `animate(p, nframes = 300, fps=3)` Increasing the number of frames and decreasing the fps will both accomplish what you are looking for. If you are still getting that error, maybe try to uninstall and reinstall the gganimate package. – Alan Dursun Nov 30 '18 at 14:55

2 Answers2

8

Not sure why you received that error, but you can set the frame rate in the animate() function call:

animate(p, nframes = 100, fps=3)
Alan Dursun
  • 655
  • 3
  • 14
2

What helped me was the duration (in seconds) option, which in combination with fps (relates to smootheness of the animation) allows you to finely tune the length and smootheness of the animation:

animate(p, fps = 10, duration = 30)
David
  • 9,216
  • 4
  • 45
  • 78