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

时间:2013-01-29 16:04:37

标签: 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

2 个答案:

答案 0 :(得分:1)

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

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

然后通过添加以下内容修改(或创建无)文件〜/ .matplotlib / matplotlibrc:

    backend : QT4Agg

然后上面的文字没有问题。

答案 1 :(得分:0)

我也有这个问题,我的工作是添加:

plt.ion()

在第一个绘图命令之前。这将打开交互式绘图模式,使错误消失。

相关问题