Python中文
首页
教程
问答
标签
搜索
登录
注册
Matplotlib.Pyplot不显示输出;No E
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我的平台如下</p> <p>Centos 6.x(运行在Win-7主机上的VirtualBox虚拟机), Python2.6.6, Matplotlib 1.3.1版, 纽比1.8.0, 科学版0.14.0.dev-bb608ba</p> <p>我正在运行下面的histogram.py代码</p> <pre><code>#!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt mu, sigma = 0, 1 # mean and standard deviation f = np.random.normal(mu, sigma, 1000) # generate feature-vector with normal distribution # plot the histogram - check the distribution count, bins, ignored = plt.hist(f, 30, normed=True) plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) * np.exp( - (bins - mu)**2 / (2 * sigma**2) ), linewidth=2, color='r') plt.xlabel('Values') plt.ylabel('Probability') plt.title('Histogram') plt.text(60, .025, r'$\mu=0,\ \sigma=1$') plt.axis([-0.4, 0.3, 0, 5]) plt.grid(True) plt.show() </code></pre> <p>但没有输出图出现。我没有收到错误,所以很难调试。</p> <p>下面是matplotlib安装的rc文件位置和后端</p> <pre><code>[hue@sandbox ~]$ python Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib >>> matplotlib.matplotlib_fname() '/usr/lib64/python2.6/site-packages/matplotlib-1.3.1-py2.6-linux-x86_64.egg/matplotlib/mpl-data/matplotlibrc' >>> matplotlib.get_backend() 'agg' </code></pre> <p>是否需要将“agg”后端修改为“Qt4Agg”或其他内容?需要我修改rc文件吗?</p> <p>注意:我检查了matplotlibrc文件,发现只有<code>backend : agg</code>。Rest所有参数都被注释。</p> <p>根据下面的评论,我尝试安装libpng,但遇到以下错误:</p> <pre><code>pngfix.o: In function `zlib_reset': /usr/lib/hue/libpng-1.6.6/contrib/tools/pngfix.c:2151: undefined reference to `inflateReset2' collect2: ld returned 1 exit status </code></pre> <p>我现在已经成功地安装了一个稳定和工作的libpng-1.5.9/zlib-1.2.7,而不是以前不稳定的libpng-1.6.6/zlib-1.2.8版本,并且两个libs都已成功安装。</p> <p>但是,尽管libpng工作稳定,我还是无法打开由python代码生成的png文件(如上所示)。VMs是否有特定的配置设置来打开.png文件?如何在WIndows主机上运行的Linux VMs上打开.png文件?</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>我也有过类似的问题。我通过在<code>import matplotlib.pyplot as plt</code>之后和之后的每个<code>plt.show()</code>之后立即添加这些行来解决这个问题:</p> <pre><code>plt.clf() plt.cla() plt.close() </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Python中两个字典的交集
3 回答
python中两个字符串上的异或操作数?
10 回答
Python中两个字符串中的类似句子
7 回答
Python中两个字符串之间的Hamming距离
3 回答
python中两个字符串之间的匹配模式
7 回答
python中两个字符串之间的按位或
8 回答
python中两个字符串之间的数据(字节)切片
8 回答
python中两个字符串之间的模式
9 回答
python中两个字符串作为子字符串的区别
1 回答
Python中两个字符串元组的比较
2 回答
Python中两个字符串列表中的公共字符串
4 回答
python中两个字符串的Anagram测试
6 回答
Python中两个字符串的正则匹配
2 回答
python中两个字符串的笛卡尔乘积
10 回答
Python中两个字符串相似性的比较
1 回答
python中两个字符串语义相似度的求法
10 回答
Python中两个字符置换成固定长度的字符串,每个字符的数目相等
9 回答
Python中两个对数方程之间的插值和平滑数据
5 回答
Python中两个对象之间的And/Or运算符
3 回答
python中两个嵌套字典中相似键的和值
3 回答