热线电话:13121318867

登录
2019-01-22 阅读量: 746
求助Matplotlib热图动画非常小

我使用的代码如下:

import numpy as np

import matplotlib

matplotlib.use("Agg")

import matplotlib.pyplot as plt

import matplotlib.animation as animation

import xarray

Writer = animation.writers['ffmpeg']

writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)

x = a[var]['lat'].values # Formatted as follows: [-32,-33,-34,-35,-36...]

y = a[var]['lon'].values # Formatted as follows: [150.2, 151.2, 153.2...]

z = np.array(a[var].values) # [[[24,22,18,23,24,24,25]

# [18,25,23,22,21,19,26]

# ...

# [12,28,19,22,25,26,19]]

# ...

# [[8,4,16,12,22,24,23,8]

# ...

# [12,28,14,7,8,13,6,12]]]

fig = plt.figure()

ax = fig.add_subplot(len(x),len(y),1)

def plot(i):

data = z[i]

heatmap = ax.pcolor(x, y, data)

ani = animation.FuncAnimation(fig, plot, interval=1, frames=20)

ani.save('im.mp4', writer=writer)

我还应该提到尝试调用plt.subplots(x,y)导致控制台冻结的原因,5分钟后它仍然没有进展。

0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子