我正在使用 matplotlib 绘制一条线,并希望在生成新值后立即更新我的线数据。但是,一旦进入循环,就不会出现任何窗口。即使打印的行表明循环正在运行。
这是我的代码:
def inteprolate(u,X):
...
return XX
# generate initial data
XX = inteprolate(u,X)
#initial plot
xdata = XX[:,0]
ydata = XX[:,1]
ax=plt.axes()
line, = plt.plot(xdata,ydata)
# If this is in, The plot works the first time, and then pauses
# until the window is closed.
# plt.show()
# get new values and re-plot
while True:
print "!"
XX = inteprolate(u,XX)
line.set_xdata(XX[:,0])
line.set_ydata(XX[:,1])
plt.draw() # no window
plt.show()
当阻塞并且plt.draw
不更新/显示窗口时,如何实时更新我的绘图?