我试图用animation.FuncAnimation
制作最简单的matplotlib动画。我不在乎效率。我不想跟踪绘制的线条和更新它们的数据(在我想要的应用程序中,这会很烦人),我只想在设置每一帧动画之前删除绘图。我以为这样的事情应该有用,但它不是。。在
import matplotlib.animation as animation
fig = Figure()
def updatefig(i):
clf()
p = plot(rand(100))
draw()
anim = animation.FuncAnimation(fig, updatefig, range(10))
至少这似乎有效:
原始代码的问题是
Figure
用大写的F(应该是figure
)写的。在否则,我建议不要使用
pylab
样式的“同一名称空间中的所有内容”方法与matplotlib
一起使用。另外,使用面向对象的接口而不是plt.draw
、plt.plot
等,将在以后节省大量的麻烦。在相关问题 更多 >
编程相关推荐