我有一个代码可以对x和y点进行时间变化动画:
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
style.use('fivethirtyeight')
fig=plt.figure(figsize=(25,25))
ax1=fig.add_subplot(1,1,1)
df3=df2.head(20)
def animate(i):
xs=[]
ys=[]
xs=df3.loc[(i-1):i,'logintude'].values
ys=df3.loc[(i-1):i,'latitude'].values
ax1.clear()
ax1.scatter(xs,ys)
ani=animation.FuncAnimation(fig,animate,frames=range(1000),interval=1000,blit=False,repeat=True)
plt.show()
运行后错误为: 460100x333779像素的图像尺寸太大。每个方向上的值必须小于2 ^ 16。 当只使用来自大型df2数据集的20个点时,我不知道这个大小从哪里来。
编辑器不允许我粘贴所有内容,因此如果足够,请仅使用箭头粘贴核心
--> 341 return printer(obj)
240 if 'png' in formats:
--> 241 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
124 bytes_io = BytesIO()
--> 125 fig.canvas.print_figure(bytes_io, **kw)
2262 bbox_inches_restore=_bbox_inches_restore,
-> 2263 **kwargs)
516 def print_png(self, filename_or_obj, *args, **kwargs):
--> 517 FigureCanvasAgg.draw(self)
--> 429 self.renderer = self.get_renderer(cleared=True)
430 # acquire a lock on the shared font cache
453 if need_new_renderer:
--> 454 self.renderer = RendererAgg(w, h, self.figure.dpi)
455 self._lastKey = key
--> 101 self._renderer = _RendererAgg(int(width), int(height), dpi)
102 self._filter_renderers = []