python - 使用 matplotlib.pyplot.plot() 绘图时出错

标签 python matplotlib macports

以下代码给出错误,我不明白为什么:

    import numpy as np
    import matplotlib.pyplot as plt
    a = np.arange(10)
    plt.plot(a)
    [<matplotlib.lines.Line2D at 0x116be8890>]
    plt.show()

    2013-01-29 10:58:18.891 Python[27257:903] *** __NSAutoreleaseNoPool(): Object 0x105b27810 of class NSCFArray autoreleased with no pool in place - just leaking
    2013-01-29 10:58:18.893 Python[27257:903] *** __NSAutoreleaseNoPool(): Object 0x105b37f60 of class __NSFastEnumerationEnumerator autoreleased with no pool in place - just leaking
    2013-01-29 10:58:18.895 Python[27257:903] *** __NSAutoreleaseNoPool(): Object 0x105bee900 of class NSObject autoreleased with no pool in place - just leaking

我有 matplotlib 1.2.0、numpy 1.6.2、python 2.7.3 和 ipython 0.13.1。这些软件包已与 macports 一起安装。这是在 Mac OS 10.6.8 上执行的,我在 10.7.5 上没有看到它。

编辑:this post shows the same error, although no solution has been clearly found

最佳答案

我还没有找到解决办法。我的解决方法是安装另一个后端:qt4。这需要做:

    sudo port install qt4-mac
    sudo port install py27-qt4

然后通过添加以下内容来修改(或创建,如果没有)文件 ~/.matplotlib/matplotlibrc:

    backend : QT4Agg

那么上面的文本就可以正常工作了。

关于python - 使用 matplotlib.pyplot.plot() 绘图时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14587075/

相关文章:

bash - 如何在 Unix 中同时写入文件和打印到终端?

c++ - 带有 mmacosx-version-min 和 Foundation header 的 MacPorts GCC 4.8.2 错误

python - NoReverseMatch at/allbook Reverse for 'random_book' with arguments '(' ', )' not found. 1 pattern(s) tried: [' info/(?P<pk>[0-9]+)\\Z']

python - 从列表中查找和排除多个匹配项的逻辑

python - pandas 当前行 * 上一行 + 上一行

python - matplotlib 中的 gnuplot linecolor 变量?

适用于 Windows、matplotlib 和 opencv 的 Python

python - 为什么调用 entry.get() 给我 "invalid command name"?

python-3.x - 参数 'c' 和 'cmap' 在 matplotlib 散点图中的表现如何?

python - 如何使用 macports 正确安装 pyGTK?