2017-08-29 84 views
1

如何在Python中绘制动画图形的正常解释在哪里?动画在Python中不起作用

我写这

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,200000): 
    line.set_ydata(sin(x+i/10.0)) # update the data 
    draw()       # redraw the canvas 

print('FPS:', 200/(time.time()-tstart)) 

,并得到公正白色窗口

enter image description here

+1

要回答您的实际问题:https://matplotlib.org/api/animation_api.html –

回答

1

尝试:

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,200000): 
    line.set_ydata(sin(x+i/10.0)) # update the data 
    draw()       # redraw the canvas 
    pause(0.5) 

随着pause时间在第二