pylab matplotlib“显示"等到窗口关闭 [英] pylab matplotlib "show" waits until window closes

查看:192
本文介绍了pylab matplotlib“显示"等到窗口关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让matplotlib"show"命令返回命令行 在显示图的同时.大多数其他绘图程序包(例如R)都可以执行此操作. 但是pylab挂起,直到绘图窗口关闭.例如:

I'd like to have the matplotlib "show" command return to the command line while displaying the plot. Most other plot packages, like R, do this. But pylab hangs until the plot window closes. For example:

import pylab
x = pylab.arange( 0, 10, 0.1)
y = pylab.sin(x)
pylab.plot(x,y, 'ro-')
pylab.show()   #  Python hangs here until the plot window is closed

我希望能够在执行命令行查询时查看绘图. 我正在使用python 2.6.6运行Debian压缩. 我的〜/.matplotlib/matplotlibrc包含

I'd like to be able to view the plot while doing command line queries. I'm running Debian squeeze with python 2.6.6. My ~/.matplotlib/matplotlibrc contains

backend      : GTKAgg

谢谢!

推荐答案

添加pylab.ion()(交互模式),然后再调用pylab.show().这将使UI在单独的线程中运行,并且show的调用将立即返回.

Add pylab.ion() (interactive mode) before the pylab.show() call. That will make the UI run in a separate thread and the call to show will return immediately.

这篇关于pylab matplotlib“显示"等到窗口关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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