An animated chart displays a sequence of static charts, often in a gif or movie format. It can be really useful to describe the evolution of a dataset, or to denote the difference between two states (going from one to another and backward). This page explains how to build an animated chart with
⏱ Quick start
An animated chart can be build with
python using the following process:
- Make a loop that outputs each step of the animation as a single chart
- Export each chart in its own file (like
- Use Image Magick to concatenate all those files into a unique
# Use image magick to transform a set of .png in a gif
# (this is bash, not python)
# (You have to be in a folder with several images called img1.png, img2.png, img3.png...)
convert -delay 80 img*.png animation.gif
Let's start with a ver basic animated scatter plot made with
image magick. The
scatter() function is used to build a scatterplot at each iteration of a loop.
savefig() is used to save each chart at
.png format. Finally,
image magick builds the gif.
The process is pretty much the same for a 3d chart. Here is an example with an animated volcano plot. Each iteration of the loop changes the camera angle, giving this feeling of travelling around the volcano.
💡 Animation ≠ Interaction
There is a common confusion between what animated and interactive charts are:
- Animated means a sequence of several static images is displayed. The user can't do anything except watching those images.
- Interactive means the user can interact with the chart: zoom in, hover over a shape to get a tooltip, click to have a menu... The user is not a spectator anymore, but also an actor.