Here, we use the ʻanimation.ArtistAnimation function of Python's graph drawing library [matplotlib](http://matplotlib.org/). As a flow, an array of drawing data (ʻims
) is prepared, and the animation is drawn by passing the array to the second argument of the ʻanimation.ArtistAnimation` function.
demo.py
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig = plt.figure()
x = np.arange(0, 10, 0.1)
ims = []
for a in range(50):
y = np.sin(x - a)
im = plt.plot(x, y, "r")
ims.append(im)
ani = animation.ArtistAnimation(fig, ims)
plt.show()
You can save the animation in gif format by adding ↓.
ani.save("hoge.gif")
I tried scatter plot animation in python http://cflat-inc.hatenablog.com/entry/2014/03/17/214719
Recommended Posts