动画在Python中不起作用

时间:2017-08-29 19:04:46

标签: python linux animation matplotlib

关于如何在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 个答案:

答案 0 :(得分: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时间