python - 动画在 Python 中不起作用

标签 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

最佳答案

尝试:

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 - 动画在 Python 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45946607/

相关文章:

iphone - 使用图像序列的 iPhone 游戏动画的内存问题

python - f-string: single '}' is not allowed Python SPARQL 查询问题

python - 那么这个疯狂的循环和 if 序列呢?改进此代码的想法?

python - Python 中的 Libtcod 访问冲突错误

python - 使用时区信息正确解析日期字符串

linux - 选项 Inone 对于 linux 命令 xargs 意味着什么?

linux - 如何创建在每个发行版上运行的静态 Go 二进制文件?

html - CSS 滚动/翻译一个元素,如果它溢出

linux - Gitlab rake 备份时间戳到别的东西

javascript - CSS/Jquery 在后台淡入淡出