首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >matplotlib图在Anaconda for Linux上不显示

matplotlib图在Anaconda for Linux上不显示
EN

Stack Overflow用户
提问于 2014-05-26 03:46:32
回答 3查看 7.7K关注 0票数 4

我已经阅读了这些,并尝试了解决方案,但仍然没有得到任何显示:

matplotlib show nothing although i called show

Why doesn't pyplot.show() work? [duplicate]

matplotlib does not show my drawings although I call pyplot.show()

我在Ubuntu 12.04上使用Python 2.7.6 |Anaconda 1.9.0 (64位)。我该如何诊断问题并尝试解决它呢?

编辑:

-First我编辑了matplotlibrc,并将后端改为GtkAgg (设置为QtAgg)。

-Then我尝试通过代码更改后端: matplotlib.rcParams' backend‘= "GtkAgg“

EDIT2 -从Spyder控制台添加详细信息(末尾没有显示绘图):

代码语言:javascript
复制
Python 2.7.6 |Anaconda 1.9.0 (64-bit)| (default, Jan 17 2014, 10:13:17) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Imported NumPy 1.8.0, SciPy 0.13.3, Matplotlib 1.3.1
Type "scientific" for more details.
>>> scientific

This is a standard Python interpreter with preloaded tools for scientific 
computing and visualization. It tries to import the following modules:

>>> import numpy as np  # NumPy (multidimensional arrays, linear algebra, ...)
>>> import scipy as sp  # SciPy (signal and image processing library)
>>> import matplotlib as mpl         # Matplotlib (2D/3D plotting library)
>>> import matplotlib.pyplot as plt  # Matplotlib's pyplot: MATLAB-like syntax
>>> from pylab import *              # Matplotlib's pylab interface
>>> ion()                            # Turned on Matplotlib's interactive mode

Within Spyder, this interpreter also provides:
    * special commands (e.g. %ls, %pwd, %clear)
    * system commands, i.e. all commands starting with '!' are subprocessed
      (e.g. !dir on Windows or !ls on Linux, and so on)

>>> plot(range(3))
[<matplotlib.lines.Line2D object at 0x3f3cd50>]
>>> show()
EN

回答 3

Stack Overflow用户

发布于 2014-05-27 06:05:35

我最终在Spyder中解决了这个问题: Preferences -> Console -> External modules -> check Install Spyder's input hook for Qt

票数 3
EN

Stack Overflow用户

发布于 2014-05-26 10:54:13

为了让您的matplotlib后端选择生效,您需要为该后端安装Python。例如,您可能正在运行基于GTK的窗口管理器,比如GNOME,但是仍然没有Python绑定。根据this的说法,合适的Ubuntu包是python-gtk。因此,打开您最喜欢的终端仿真器并输入

代码语言:javascript
复制
sudo apt-get install python-gtk

(您需要管理员权限才能完成此操作)。重新启动python/matplotlib会话,就可以开始了。

票数 2
EN

Stack Overflow用户

发布于 2015-09-17 03:17:29

我在Mavericks上,通过在matplotlibrc中将后端改为Qt4Agg解决了这个问题。(根据此处的另一个答案:Why doesn't pyplot.show() work?)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23859333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档