这可能不是最佳方法,但是我发现文档/示例也不足够。
我采用的是以下解决方案:使用animation.FuncAnimation调用函数。在该函数中清除并重新绘制,如下所示:
from __future__ import divisionfrom matplotlib import cmfrom mpl_toolkits.mplot3d import Axes3Dimport matplotlib.pyplot as pltimport mpl_toolkits.mplot3d.axes3d as p3import matplotlib.animation as animationimport numpy as npplot_args = {'rstride': 1, 'cstride': 1, 'cmap': cm.bwr, 'linewidth': 0.01, 'antialiased': True, 'color': 'w', 'shade': True}soln = np.zeros((size, size))midpoint = size // 2soln[midpoint, midpoint] = 1#first frameX = range(size)Y = range(size)X, Y = np.meshgrid(X, Y)plot = ax.plot_surface(X, Y, soln, **plot_args)pam_ani = animation.FuncAnimation(fig, data_gen, fargs=(soln, plot), interval=30, blit=False)def data_gen(framenumber, soln, plot): #change soln variable for the next frame ... ax.clear() plot = ax.plot_surface(X, Y, soln, **plot_args) return plot,
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)