在不妨碍执行的情况下绘制线条 [英] plotting lines without blocking execution

查看:47
本文介绍了在不妨碍执行的情况下绘制线条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 matplotlib 绘制图表.

I am using matplotlib to draw charts and graphs.

当我使用命令 show()绘制图表时,我在此命令处的代码块.

When I plot the chart using the command show() my code blocks at this command.

我想用新数据刷新我的值列表,而不是刷新背景上的图像.如何在不每次关闭带有图形的窗口的情况下做到这一点?下面是我使用的代码

I would like to refresh my list of values with new data , and than refresh the image on the background. How to do that without closing each time the window with the graph? Below is the code I am using

import pylab
a = (1,2,3,4)
pylab.plot(a)
pylab.show() # blocks here

推荐答案

在以 -pylab 开始的 IPython 中,它不应该阻塞.

In IPython started with -pylab it should not block.

否则:使用 ion()可以打开交互模式. show()不会阻止您的系统不再.每个 draw()plot(x, y) 都会更新您的绘图.

Otherwise: With ion() you turn the interactive mode on. show() does not block your system anymore. Every draw() or plot(x, y) updated your plot.

ioff()关闭交互模式.如果您添加大量数据并且不添加数据,则很有用想更新每一个小细节.

ioff() turns interactive mode off. Useful if you add lots of data and don't want to update every little detail.

另请参见: http://www.scipy.org/Cookbook/Matplotlib/Animations

这篇关于在不妨碍执行的情况下绘制线条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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