我有一個python代碼,我在其中計算大量參數值的數量,然後將數量作爲參數的函數繪製。這裏是不過我想,該地塊得到動態更新,使得每個計算q
陣列的一個新元素時它被添加到情節的例子實時更新python中的圖形
t = np.linspace(1,100,10000)
q = np.zeros(10000)
for i in np.arange(10000)
q[i] = func(t[i])
plt.plot(t,q)
plt.show()
。我怎樣才能做到這一點?
我有一個python代碼,我在其中計算大量參數值的數量,然後將數量作爲參數的函數繪製。這裏是不過我想,該地塊得到動態更新,使得每個計算q
陣列的一個新元素時它被添加到情節的例子實時更新python中的圖形
t = np.linspace(1,100,10000)
q = np.zeros(10000)
for i in np.arange(10000)
q[i] = func(t[i])
plt.plot(t,q)
plt.show()
。我怎樣才能做到這一點?
from pylab import *
import time
ion()
tstart = time.time() # for profiling
x = arange(0,2*pi,0.01) # x-array
line, = plot(x,sin(x))
for i in arange(1,200):
line.set_ydata(sin(x+i/10.0)) # update the data
draw() # redraw the canvas
print 'FPS:' , 200/(time.time()-tstart)
從我把意見後撕開......
http://stackoverflow.com/questions/5179589/how-to-achieve-continuous-3d-plotting-ie-update- a-figure-using-python-and-ma –
http://stackoverflow.com/questions/15930529/python-matplotlib-dynamically-update-plot-array-length-not-known-a-priori – tacaswell