【问题标题】:Error when plotting with matplotlib.pyplot.plot()使用 matplotlib.pyplot.plot() 绘图时出错
【发布时间】:2013-01-29 16:04:36
【问题描述】:

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

    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

【问题讨论】:

  • This link 如果您还没有看到它,可能会帮助您。
  • 谢谢。我以前看过它并检查我是否安装了 pyobjc。事实证明,我也安装了带有 macports 的 PyObjC 2.4 和 PyObjC-cocoa 2.4。

标签: python matplotlib macports


【解决方案1】:

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

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

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

    backend : QT4Agg

那么上面的文字就没有问题了。

【讨论】:

    【解决方案2】:

    我也有这个问题,我的解决方法是添加:

    plt.ion()
    

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

    【讨论】:

      猜你喜欢
      • 2017-07-09
      • 1970-01-01
      • 2020-09-17
      • 1970-01-01
      • 2017-08-30
      • 1970-01-01
      • 1970-01-01
      • 2016-11-15
      • 1970-01-01
      相关资源
      最近更新 更多