有類似的問題here但我沒有相同的問題。下面是我的數據集的快照:Matplotlib動畫顯示爲空
從本質上講,我想動畫隨着時間的落客座標。正如你所看到的日期排序dropoff_datetime
。這是我的代碼(非常類似於上面的問題)。
fig = plt.figure(figsize=(10,10))
ax = plt.axes(xlim=xlim, ylim=ylim)
points, = ax.plot([], [],'.',alpha = 0.4, markersize = 0.05)
def init():
points.set_data([], [])
return points,
# animation function. This is called sequentially
def animate(i):
x = test["dropoff_longitude"]
y = test["dropoff_latitude"]
points.set_data(x, y)
return points,
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=100, interval=20, blit=True)
plt.show()
與上面鏈接的問題類似,我的情節只是顯示爲空。我相信我正確地編碼它,不同於上面的鏈接,我確實看到了座標在不斷變化。我不知道爲什麼情節是空的。
_I確實看到了那個座標切換time_:聽起來好像是你所期待的。 _我不確定問題是什麼:如果你沒有描述你的問題,我們也不知道。 – pingul
對不起,我認爲我參考上面的鏈接會清除那個。我更新了我的帖子。即使一切看起來都設置得當,我的情節是空的。 – madsthaks