pyplot.show()为什么不起作用? [英] Why doesn't pyplot.show() work?

查看:31
本文介绍了pyplot.show()为什么不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
matplotlib 不显示我的绘图,尽管我调用了 pyplot.show()

我是Matplotlib的新手,并且遇到了此问题.我正在使用 Ubuntu 系统.我从 Matplotlib 0.99 开始,意识到我真的需要新版本中的triplot"新功能.所以我下载了最新版本

I'm a newbie to Matplotlib and have encountered this problem. I'm using a Ubuntu system. I started with Matplotlib 0.99 and realized that I really need the new feature of "triplot" in the newer versions. So I downloaded the newest version by

git clone git://github.com/matplotlib/matplotlib.git

并安装它.但是,当我以交互方式使用 python 时,pyplot.show() 没有显示我绘制的图形,也没有响应任何错误消息.pyplot.show() 在旧版 matplotlib 0.99 中确实有效.

and installed it. However, when I work with python interactively, pyplot.show() does not show me the figure I plot, nor did it responded with any error message. pyplot.show() did work in the old version of matplotlib 0.99.

更具体地说,我在包内导入matplotlib"或模块似乎没有问题;我可以生成一堆数字的pdf文件,但是我无法通过在代码末尾键入 pyplot.show()来显示数字.谁能帮我?谢谢!

To be more specific, I seemed to have no problem importing "matplotlib" or modules inside the package; I can generate pdf files of a bunch of figures, but I just can't have the figure show up by typing pyplot.show() at the end of my code. Can anyone help me? Thank you!

推荐答案

我遇到了同样的问题,并按照

I had the same issue and solved it by setting the appropriate display backend, following matplotlib does not show my drawings although I call pyplot.show()

有两种方法可以实现:

1.在您的代码中设置后端,在导入 matplotlib 之后:

1.Set the backend in your code, right after importing matplotlib:

import matplotlib
matplotlib.rcParams['backend'] = "Qt4Agg"

2.或者在你的 matplotlibrc 文件中定义你的后端(由 matplotlib.matplotlib_fname() 给出):

2.Or define your backend inside your matplotlibrc file (as given by matplotlib.matplotlib_fname()):

backend      : Qt4Agg

此处的更多信息: http://matplotlib.sourceforge.net/users/customizing.html

这篇关于pyplot.show()为什么不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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