Other sites

Animated plots in R and LaTeX

I like to use animated plots in my talks on functional time series, partly because it is the only way to really see what is going on with changes in the shapes of curves over time, and also because audiences love them! Here is how it is done.

For LaTeX, you need to create every frame as a separate graphics file. Here is an example. First the R code:

library(demography)
nyears 1)
x$rate$male[,1:(i-1)]

This creates a series of pdf files in the figs directory, named frmale1.pdf, …, frmale191.pdf. In the LaTeX file, you need to load the animate package. Then the following command will do the magic: