gpt4 book ai didi

python-2.7 - matplotlib 图不显示在 Anaconda for Linux 上

转载 作者:行者123 更新时间:2023-12-03 16:36:02 25 4
gpt4 key购买 nike

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

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 位)。
我该如何诊断问题并尝试解决它?

编辑:

-首先我编辑了matplotlibrc并将后端更改为GtkAgg(设置为QtAgg)。

- 然后我尝试通过代码更改后端:matplotlib.rcParams['backend'] = "GtkAgg"

EDIT2 - 从 Spyder 控制台添加细节(最后没有显示图):

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()

最佳答案

我最终通过在 Spyder 中执行此操作来解决:
Preferences -> Console -> External modules -> check Install Spyder's input hook for Qt

关于python-2.7 - matplotlib 图不显示在 Anaconda for Linux 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23859333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com