Python 和 matplotlib - 没有显示简单图表,没有错误 [英] Python and matplotlib - simple chart not showing, no errors

查看:59
本文介绍了Python 和 matplotlib - 没有显示简单图表,没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容与matplotlib一样简单.

Below is about as simple can get with matplotlib.

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
print 'done'

当我跑步时,我没有错误,也没有图表,并且直接打印完成".

When I run, I get no errors, no charts, and goes straight to printing 'done'.

我使用 easy_install 安装在 ubuntu 10.04 上.

I installed on ubuntu 10.04 using easy_install.

推荐答案

您的后端可能是非交互式后端(例如Agg").您在matplotlibrc文件中有后端设置吗?

Your backend is probably a non-interactive backend (such as 'Agg'). Have you got the backend setup in your matplotlibrc file?

试试:

import matplotlib
matplotlib.use('TkAgg') # or some other backend which you have installed

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
print 'done'

您可以使用以下命令找到 matplotlib rc 文件的位置:

You can find the location of your matplotlib rc file with:

import matplotlib
import os

print os.path.join(matplotlib.get_configdir(), 'matplotlibrc')

您应该寻找类似 backend: Agg 的东西.

You should be looking for something like backend: Agg.

这篇关于Python 和 matplotlib - 没有显示简单图表,没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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