相关疑难解决方法(0)

使用matplotlib中的pcolormesh例程动画,如何初始化数据?

我想一个动画pcolormeshmatplotlib.我见过许多使用包动画的例子,其中大多数使用一维绘图例程,其中一些使用imshow().首先,我想使用FuncAnimation routine.我的问题是,首先,我不知道我是否可以初始化情节

fig,ax = plt.subplots()
quad = ax.pcolormesh(X,Y,Z)
Run Code Online (Sandbox Code Playgroud)

我尝试了几个简单的行:

fig,ax = plt.subplots()
quad = ax.pcolormesh([])

def init():
    quad.set_array([])
    return quad,

def animate(ktime):  
    quad.set_array(X,Y,np.sin(Z)+ktime)
return quad,

anim = animation.FuncAnimation(fig,animate,init_func=init,frames=Ntime,interval=200,blit=True)

plt.show()
Run Code Online (Sandbox Code Playgroud)

顺便说一句,如何设置标签和动画情节?如果标题显示的是时间变化的数字,我可以为标题设置动画吗?谢谢

python animation matplotlib multidimensional-array

8
推荐指数
3
解决办法
9815
查看次数