Python- 1 秒绘图连续演示 [英] Python- 1 second plots continous presentation

查看:39
本文介绍了Python- 1 秒绘图连续演示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一本包含数据的字典.对于每个条目,我想显示 1 秒的图并移动到下一个.要显示的图已经在外部脚本中编码.我想自动执行此操作.因此,我遍历字典,显示第一组绘图[0],关闭绘图[0],显示绘图[1]关闭绘图[1] ...我想设置显示时间,例如1秒,然后将绘图显示为全屏.演示过程中不想碰电脑的问题.

I have a dictionary with data. For every entry I would like to display plots for 1 second and move to the next one. The plots to display are already coded in external scripts. I would like to do this automatically. So I loop through the dict, display first set of plots[0], close the plots[0], display plots[1] close plots[1] ... I would like to set up display time for let say 1 second and have the plot as full screen. The problem that during the presentation I don't want to touch the computer.

import pylab as pl
import numpy as np

x = np.arange(-np.pi, np.pi, 0.1)         # only for the example purpose
myDict = {"sin":np.sin(x), "cos":np.cos(x), "exp":np.exp(x)}
for key in myDict:
    print myDict[key]
    pl.plt.plot(myDict[key])              # in origin coming from external function
    pl.plt.plot(x)                        # in origin coming from external function
    pl.plt.show()

有谁知道上面应该使用什么函数以及如何修改吗?

Does anyone know what function should be used and how to modify above?

推荐答案

一个简单的方法是使用 plt.pause(1).更复杂的方法是使用 matplotlib.animate 模块.见

A simple method is to use plt.pause(1). A more sophisticated method is to usethe matplotlib.animate module. See pylab.ion() in python 2, matplotlib 1.1.1 and updating of the plot while the program runs

示例api, 教程

这篇关于Python- 1 秒绘图连续演示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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