Python 2.7 matplotlib xkcd在mac上不工作

Python 2.7 matplotlib xkcd在mac上不工作,python-2.7,matplotlib,plot,Python 2.7,Matplotlib,Plot,我在可视化matplotlib xkcd绘图时遇到了一个小问题。 通过简单地尝试执行在上找到的示例。 执行xkcd.py时,绘图的可视化不起作用 我得到这个错误信息: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wra

我在可视化matplotlib xkcd绘图时遇到了一个小问题。 通过简单地尝试执行在上找到的示例。 执行xkcd.py时,绘图的可视化不起作用 我得到这个错误信息:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/figure.py", line 1084, in draw
    func(*args)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/axes/_base.py", line 2092, in draw
    a.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/lines.py", line 712, in draw
    drawFunc(renderer, gc, tpath, affine.frozen())
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/lines.py", line 1067, in _draw_lines
    self._lineFunc(renderer, gc, path, trans)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/lines.py", line 1107, in _draw_solid
    renderer.draw_path(gc, path, trans)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/patheffects.py", line 115, in draw_path
    rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/patheffects.py", line 217, in draw_path
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/backends/backend_macosx.py", line 58, in draw_path
    gc.draw_path(path, transform, linewidth, rgbFace)
AttributeError: 'GraphicsContextBase' object has no attribute 'draw_path'
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/figure.py", line 1084, in draw
    func(*args)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/axes/_base.py", line 2092, in draw
    a.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/axis.py", line 1102, in draw
    tick.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/axis.py", line 244, in draw
    self.tick1line.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/lines.py", line 757, in draw
    rgbaFace)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/patheffects.py", line 127, in draw_markers
    **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/backend_bases.py", line 266, in draw_markers
    rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/patheffects.py", line 115, in draw_path
    rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/patheffects.py", line 217, in draw_path
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-intel.egg/matplotlib/backends/backend_macosx.py", line 58, in draw_path
    gc.draw_path(path, transform, linewidth, rgbFace)
AttributeError: 'GraphicsContextBase' object has no attribute 'draw_path'
如果我试图保存这些绘图,我会得到两个完美的png文件:


我真的不明白为什么

正如评论员所说,macOSX后端不受支持。在OS X 10.10.1上使用Python 3.4时,TkAgg工作正常

import matplotlib
matplotlib.use("TkAgg")

因为xkcd筛选器不适用于macOSX后端。我建议使用一种基于Agg的后端(QtAgg、TxAgg、WxAgg、GtkAgg)