matplotlib 绘图窗口不会出现 [英] matplotlib plot window won't appear

查看:48
本文介绍了matplotlib 绘图窗口不会出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 64 位 Python 2.7.3.我为 64 位安装了 pandas 和 matplotlib 1.1.1.现在,我的图都没有显示.在尝试从几个不同的数据帧进行绘图后,我沮丧地放弃并尝试了 http://pandas.pydata.org/pandas-docs/dev/visualization.html:

I'm using Python 2.7.3 in 64-bit. I installed pandas as well as matplotlib 1.1.1, both for 64-bit. Right now, none of my plots are showing. After attempting to plot from several different dataframes, I gave up in frustration and tried the following first example from http://pandas.pydata.org/pandas-docs/dev/visualization.html:

输入:

import matplotlib.pyplot as plt
ts = Series(randn(1000), index=date_range ('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
pylab.show()

输出:

Axes(0.125,0.1;0.775x0.8)

并且没有出现绘图窗口.我读过的其他 StackOverflow 线程表明我可能缺少 DLL.有什么建议吗?

And no plot window appeared. Other StackOverflow threads I've read suggested I might be missing DLLs. Any suggestions?

推荐答案

我完全不相信这是 Pandas 的问题.

I'm not convinced this is a pandas issue at all.

是否

import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()

提出情节?

如果不是:

你是如何安装 matplotlib 的?它是从源代码还是您是从包管理器/预构建的二进制文件中安装的?

How did you install matplotlib? Was it from source or did you install it from a package manager/pre-built binary?

我怀疑如果你跑:

import matplotlib            
print matplotlib.rcParams['backend']

结果将是一个非 GUI 后端(几乎可以肯定是Agg").这表明您没有合适的 GUI 工具包可用(我个人使用 Tkinter,这意味着我的后端报告为TkAgg").

The result will be a non-GUI backend (almost certainly "Agg"). This suggests you don't have a suitable GUI toolkit available (I personally use Tkinter which means my backend is reported as "TkAgg").

解决方案取决于您的操作系统,但如果您可以安装 GUI 库(Tkinter、GTK、QT4、PySide、Wx 之一),那么 pyplot.show() 应该会弹出为你打开一扇窗.

The solution to this depends on your operating system, but if you can install a GUI library (one of Tkinter, GTK, QT4, PySide, Wx) then pyplot.show() should hopefully pop up a window for you.

HTH,

这篇关于matplotlib 绘图窗口不会出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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