如何正确地随着时间动画静态背景图cartopy+动态轮廓线f +动态标题

问题描述

我一直试图在地图上创建浓度的contourf表示的动画,我一直使用的主要代码是:

tiler = Stamen('terrain-background')

fig,ax = plt.subplots(figsize=[10,10],subplot_kw=dict(projection=ccrs.AlbersEqualArea()))
    ax.set_extent([-6.5,-4.5,35.5,37])
    ax.add_image(tiler,11)
    ax.gridlines(draw_labels=True,dms=True,x_inline=False,y_inline=False)
    cf = ax.contourf(LON,LAT,Z[:,:,0]*np.nan,levels=[1e-3,1e-2,1e-1,10,100,1000],cmap=plt.get_cmap('gist_heat_r'),alpha = 0.65,antialiased=True,norm = LogNorm(),transform=ccrs.PlateCarree()
        )
    cbar = fig.colorbar(cf)
    cbar.set_label('mg/m^3')
    
    def update(i):
        ax.contourf(LON,i],transform=ccrs.PlateCarree()
            )
        plt.title('{} average concentration. date: {}'.format(avg_label[i],date_label[i]))      
    
    ani = animation.FuncAnimation(fig,update,frames=Z.shape[2],interval=1500)
    plt.show()

一切都可以,但contourf表示法不会在每个步骤中刷新信息。在每个步骤中,仍然会显示较旧帧的先前表示形式。因此,最后,最后一帧的结果等于四个表示帧的重叠。

如何在不丢失背景图的情况下更改此行为?我只想在每个帧中显示Z [:,:,i]。

我在最后一帧中得到的图形是这样的:

提前谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)