我正在繪製使用matplotlib的線,並希望在生成新值後立即更新線數據。但是,一旦進入循環,就不會出現窗口。即使打印的行表示循環正在運行。動態更新python中的圖形線
這裏是我的代碼:
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
不更新/顯示窗口?
also http://stackoverflow.com/questions/16447812/make-matplotlib-draw-only-show-new-point/16448826#16448826 – tacaswell