The trick used to make animated plots is always the same: realise a set of several images, and display them one after another in a .gif file with Image Magick. Here I do a loop where each iteration make a scatterplot. The position of the unique dot slowly evolves. Then, I use a bash command line to transform the set of images in an animation!
# libraries import matplotlib.pyplot as plt import seaborn as sns my_dpi=96 # I build a data set: 10 individuals and 5 variables for each for i in range(0,10): fig = plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi) plt.scatter(i, i*i, s=40+i*600, alpha=0.5, edgecolors="grey", linewidth=2) plt.xlim(0, 10) plt.ylim(0, 100) filename='step'+str(i)+'.png' plt.savefig(filename, dpi=96) plt.gca()
Running these lines of code you should get several files in your working directory: step1.png, step2.png… Now we can use a Bash one liner to transform it in a gif:
# Then use image magick (this is bash, not python) convert -delay 80 *.png animated_chart.gif