栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

python 2,matplotlib 1.1.1中的pylab.ion()和程序运行时的绘图更新

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python 2,matplotlib 1.1.1中的pylab.ion()和程序运行时的绘图更新

您希望该

pause
功能使gui框架有机会重新绘制屏幕:

import pylabimport timeimport randomimport matplotlib.pyplot as pltdat=[0,1]fig = plt.figure()ax = fig.add_subplot(111)Ln, = ax.plot(dat)ax.set_xlim([0,20])plt.ion()plt.show()    for i in range (18):    dat.append(random.uniform(0,1))    Ln.set_ydata(dat)    Ln.set_xdata(range(len(dat)))    plt.pause(1)    print 'done with loop'

您无需

Line2D
每次都创建一个新对象,只需更新现有对象中的数据即可。

说明文件:

pause(interval)    Pause for *interval* seconds.    If there is an active figure it will be updated and displayed,    and the gui event loop will run during the pause.    If there is no active figure, or if a non-interactive backend    is in use, this executes time.sleep(interval).    This can be used for crude animation. For more complex    animation, see :mod:`matplotlib.animation`.    This function is experimental; its behavior may be changed    or extended in a future release.

一个真正的过度杀伤方法是使用

matplotlib.animate
模块。另一方面,如果您愿意的话,它为您提供了一种保存数据的好方法从我对[Python的回答中-1秒连续绘图。

示例,api,教程



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/645487.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号