我遇到了这个简单的例子,可以帮助我解决我的问题:
"""
Pyplot animation example.
The method shown here is only for very simple, low-performance
use. For more demanding applications, look at the animation
module and the examples that use it.
"""
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(6)
y = np.arange(5)
z = x * y[:,np.newaxis]
for i in xrange(5):
if i==0:
p = plt.imshow(z)
fig = plt.gcf()
plt.clim() # clamp the color limits
plt.title("Boring slide show")
else:
z = z + 2
p.set_data(z)
print "step", i
plt.pause(0.5)
这在pyplot界面中显示动画,但我想以某种电影格式保存这个动画,有什么办法吗?