0
我正在试图制作一个框架,使用matplotlib动态重新绘制数据。然而,每次我运行代码时,不是更新绘图,绘图窗口停止响应,直到代码完成,然后绘制最终的图形。Spyder冻结动态绘图
是在Spyder的“功能”中,还是我写错了什么?有没有任何解决方法,所以它会实际工作?
import matplotlib.pyplot as plt
import time as t
def read_data():
#retrieve the data, whatever
def update_plot(ax):
time, hw = read_data()
ax.clear()
ax.plot(time, hw)
fig_hw = plt.figure()
ax_hw = fig_hw.add_subplot(111)
plt.ion()
for i in range(100):
update_plot(ax_hw)
plt.draw()
t.sleep(0.1)