动画在Python中不起作用 [英] Animation doesn't work in Python

查看:236
本文介绍了动画在Python中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何在Python中绘制动画图的正常解释是什么?

Where is normal explanation on how to plot animated graphs in 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))

并且只有白色的窗口

推荐答案

尝试:

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)

暂停时间为

这篇关于动画在Python中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆