我有大約8個月的每小時數(shù)據(jù),我想以動畫風格繪制。我目前能夠做到這一點,但是隨著數(shù)據(jù)量的增加,它變得非常慢。請注意,我甚至將間隔設置為僅1ms!有沒有辦法確保動畫不會變慢?此外,如何以這種風格同時繪制多條線?這是我到目前為止的代碼:x = benchmark_returns.indexy = benchmark_returns['Crypto 30'] #Would preferrably like to plot #benchmark_returns[['Crypto 30', 'NASDAQ', 'Dow Jones 30', 'S&P 500']] at the same timefig, ax = plt.subplots()line, = ax.plot(x, y, color='k')def update(num, x, y, line): line.set_data(x[:num], y[:num]) return line,ani = animation.FuncAnimation(fig, update, fargs=[x, y, line], interval = 1, blit=True)plt.show()以下是我的數(shù)據(jù)幀的示例: Crypto 30 Dow Jones 30 NASDAQ S&P 5002019-06-09 00:00:00 100.00000 100.0 100.0 100.02019-06-09 01:00:00 95.78653 100.0 100.0 100.02019-06-09 02:00:00 95.78653 100.0 100.0 100.02019-06-09 03:00:00 95.78653 100.0 100.0 100.02019-06-09 04:00:00 95.78653 100.0 100.0 100.02019-06-09 05:00:00 95.78653 100.0 100.0 100.02019-06-09 06:00:00 95.78653 100.0 100.0 100.02019-06-09 07:00:00 95.78653 100.0 100.0 100.02019-06-09 08:00:00 95.78653 100.0 100.0 100.02019-06-09 09:00:00 95.78653 100.0 100.0 100.0
1 回答

慕尼黑8549860
TA貢獻1818條經驗 獲得超11個贊
顯示動畫受到計算機重繪繪圖的速度的限制 - 因此間隔不一定決定動畫更新的實際速率。通過以下方式保存動畫plt.show()
ani.save("animation.mp4")
或類似的將允許您以指定的速度查看動畫。
添加回答
舉報
0/150
提交
取消