【发布时间】:2023-02-13 19:14:33
【问题描述】:
我想通过实时重新绘制一条新曲线(有 100 个点)来更新绘图。
这有效:
import time, matplotlib.pyplot as plt, numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
t0 = time.time()
for i in range(10000000):
x = np.random.random(100)
ax.clear()
ax.plot(x, color='b')
fig.show()
plt.pause(0.01)
print(i, i/(time.time()-t0))
但只有 ~10 FPS,这看起来很慢。
在 Matplotlib 中执行此操作的标准方法是什么?
我已经读过 How to update a plot in matplotlib 和 How do I plot in real-time in a while loop using matplotlib? 但这些案例不同,因为它们向现有地块添加新点.在我的用例中,我需要重新绘制所有内容并保留 100 分。
【问题讨论】:
标签: python matplotlib