【问题标题】:Python matplotlib animation of a constantly updated data feed不断更新的数据馈送的 Python matplotlib 动画
【发布时间】:2015-09-12 09:32:45
【问题描述】:

我正在尝试使用 matplotlib 中的动画制作卫星可视化工具。我想绘制一个 5 图像动画,然后在每次出现新图像时不断更新此动画。

我可以像这样对最后 5 张图像进行动画处理:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation

fig = plt.figure(figsize=(20,10),frameon=True,tight_layout=True)
ax = plt.subplot(111, frameon=False)


map = Basemap(projection='cyl',resolution = 'i', area_thresh = 0.1,llcrnrlon=-75, llcrnrlat=-42,\
    urcrnrlon=-36, urcrnrlat=-10)
map.drawlsmask(land_color='white', ocean_color='lightsteelblue', lakes=False)
map.drawcoastlines(color='grey')

map.drawcountries(color='grey')
map.drawparallels(np.arange(-80., 81., 10.), labels=[1,0,0,0], fontsize=10)
map.drawmeridians(np.arange(-180., 181., 10.), labels=[0,0,0,1], fontsize=10)
map.drawstates()
map.drawmapboundary()

imgs = []

im = map.imshow(sat1,cmap='Greys',vmin=190, vmax=300,origin='upper')
imgs.append([im])

im2 = map.imshow(sat2,cmap='Greys',vmin=190, vmax=300,origin='upper')
imgs.append([im2])

im3 = map.imshow(sat3,cmap='Greys',vmin=190, vmax=300,origin='upper')
imgs.append([im3])

im4 = map.imshow(sat4,cmap='Greys',vmin=190, vmax=300,origin='upper')
imgs.append([im4])

im5 = map.imshow(sat5,cmap='Greys',vmin=190, vmax=300,origin='upper')
imgs.append([im5])


ani = animation.ArtistAnimation(fig,imgs, interval=500)

plt.show()

我还可以使用FuncAnimation 显示一张图像并使用最新的图像更新该图像。但是如何更新ArtistAnimation 显示的列表?

我需要del imgs[0] 并附加一个新的imshow。这样我将始终显示最新的 5 张卫星图像。

这可能吗?

【问题讨论】:

    标签: python animation matplotlib matplotlib-basemap


    【解决方案1】:

    matplotlib 并不真正适合这样的问题。 GR 框架可能是您正在寻找的:http://gr-framework.org/

    【讨论】:

      猜你喜欢
      • 2015-03-13
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多