我发现了这个关于动画的精彩简短教程:
http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/
但是我无法制作相同方式的动画 imshow() 图。我试图替换一些行:
# First set up the figure, the axis, and the plot element we want to animate
fig = plt.figure()
ax = plt.axes(xlim=(0, 10), ylim=(0, 10))
#line, = ax.plot([], [], lw=2)
a=np.random.random((5,5))
im=plt.imshow(a,interpolation='none')
# initialization function: plot the background of each frame
def init():
im.set_data(np.random.random((5,5)))
return im
# animation function. This is called sequentially
def animate(i):
a=im.get_array()
a=a*np.exp(-0.001*i) # exponential decay of the values
im.set_array(a)
return im
但我遇到了错误你能帮我把它运行起来吗?先感谢您。最好的,