Animation using magick and ´gganimate´
See lecture notes about animation and more importantly the answer to the lab.
Low-level approach - magick
Approach to draw every frame of the animation. More work but also more control.
Basic steps to produce animation:
- Assign value (fx.
img) to call ofmagick::image_graphto open amagickgraphics device - Run a loop that draws each frame of the animation
- Call
dev.off()to close themagickgraphics device - Run
image_animate(img)
High-level approach - gganimate
NOTE! Install package gifski. If installed,
gganimatewill make sure to use that as the backend when creating the GIFs
See the getting started article as well as run examples in references section of each transition_... function.
Create animation “superimposed” onto static image
See example how to do this in this model answer
Misc notes about gganimate
- If using
exit/enter_xxfunction you NEED to specify a grouping aesthetic EXPLICITLY, which will devide data into subsets that the transitions will display in each frame. - To slow down the animation, assign it a value
p, and then useanimate(p, fps = 1)fx. to control the frames pr. second.