matplotlib xkcd 无法在 Mac 上运行

2024-05-15

我在可视化 matplotlib xkcd 图时遇到小问题。 通过简单地尝试执行上找到的示例matplotlib.org http://matplotlib.org/examples/showcase/xkcd.html。 当我执行 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")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

matplotlib xkcd 无法在 Mac 上运行 的相关文章

  • 导入错误:没有名为 _ssl 的模块

    带 Python 2 7 的 Ubuntu Maverick 我不知道如何解决以下导入错误 gt gt gt import ssl Traceback most recent call last File
  • 改变字典的哈希函数

    按照此question https stackoverflow com questions 37100390 towards understanding dictionaries 我们知道两个不同的字典 dict 1 and dict 2例
  • 为什么我只能用管理员权限才能导入Python中的某些模块?

    我正在努力解决 Python 2 7 中的一些奇怪问题 我写了一个很长的工具 在其中导入不同的模块 我必须首先使用它安装pip 该工具将在公司内部共享 不同的用户在其特定机器上拥有不同的权限 当另一个用户登录我的计算机 我在那里拥有管理员权
  • 在 MatPlotLib 中检索自定义破折号

    关于如何使用 matplotlib 线中设置自定义破折号有很多问题Line2D set linestyle and Line2D set dashes 但是 我似乎找不到在设置后检索破折号图案的方法 这是在主站点上设置破折号的示例 我将在下
  • 每个 X 具有多个 Y 值的 Python 散点图

    我正在尝试使用 Python 创建一个散点图 其中包含两个 X 类别 cat1 cat2 每个类别都有多个 Y 值 如果每个 X 值的 Y 值的数量相同 我可以使用以下代码使其工作 import numpy as np import mat
  • 绘制与Fig.show()内联的IPython Notebook图形?

    我正在使用 IPython Notebook 调用内联模式 pylab inline 以下代码立即在单元格处绘制一个图形 fig plt figure axes fig add axes 0 0 1 1 不过 我想在一个单元格中创建绘图 轴
  • 使用 Python 的 matplotlib 选择在屏幕上显示哪些图形以及将哪些图形保存到文件中

    我想用Python创建不同的图形matplotlib pyplot 然后 我想将其中一些保存到文件中 而另一些则应使用show 命令 然而 show 显示all创建的数字 我可以通过调用来避免这种情况close 创建我不想在屏幕上显示的绘图
  • 线性判别分析图

    如何将样本 ID 行号 作为标签添加到此 LDA 图中的每个点 library MASS ldaobject lt lda Species data iris plot ldaobject panel function x y points
  • Google App Engine 实例不断快速关闭

    所以我已经使用应用程序引擎很长一段时间了 没有任何问题 我知道 如果应用程序有一段时间没有被访问者点击 那么实例将关闭 并且第一个访问该网站的访问者将有几秒钟的延迟 同时新实例启动 然而 最近这些实例似乎只在很短的时间内保持活动状态 有时不
  • Matplotlib imshow:如何在矩阵上应用蒙版

    我正在尝试以图形方式分析二维数据 matplotlib imshow在这方面非常有用 但我觉得如果我可以从矩阵中排除一些单元格 超出感兴趣范围的值 我可以更多地利用它 我的问题是这些值使我感兴趣的范围内的色彩图 变平 排除这些值后 我可以获
  • PyQt:数据不可 JSON 序列化

    我是 PyQt GUI 的新手 我想获取a的数据QLineEdit文本框 为此我正在使用text 方法 我正在获取数据 但数据类型是QString 我需要将其作为 json 数据传输到服务器 为此我使用json dumps 方法 但我收到错
  • pyplot 中的等宽绘图大小,同时保持纵横比相等

    我想让两个图具有相同的宽度 但是生成的代码缩小了 imshow 图 xx np linspace 0 0 255 5 512 yy np linspace 0 0 255 5 512 Func np random rand len xx l
  • Vimeo API:获取下载所有视频文件的链接列表

    再会 我正在尝试从 Vimeo 帐户获取所有视频文件的列表 直接下载的链接 有没有办法在 1 GET 请求中做到这一点 好的 如果是API限制的话 就100倍 我有硬编码脚本 我在其中发出 12 个 GET 请求 1100 多个视频 根据文
  • 将图与热图(可能是对数)配对?

    How to create a pair plot in Python like the following but with heat maps instead of points or instead of a hex bin plot
  • 在 R 中绘制对数正态概率密度

    我正在尝试在 R 中生成对数正态概率密度图 其中包含 3 个不同的均值对数和标准差对数 我尝试了以下方法 但我的图表太丑了 看起来一点也不好看 x lt seq 0 10 length 100 a lt dlnorm x meanlog 0
  • 有没有办法使用 Python Pandas 读取所有行,直到遇到空行

    我在 Excel 中有很多行 并且这些行在空行之后填充有垃圾值 有没有办法使用 Python pandas 只读取 Excel 中第一个空行之前的记录 我不知道 read excel 是否可以做到这一点 如果您从 Excel 导入空行 这些
  • PySpark 使用统计信息写入 Parquet 二进制列(signed-min-max.enabled)

    我找到了这张 apache parquet 票https issues apache org jira browse PARQUET 686 https issues apache org jira browse PARQUET 686被标
  • Python 3d 绘图设置固定色阶

    我正在尝试绘制两个 3d 数组 第一个数组的 z 值在范围内 0 15 0 15 第二个来自 0 001 0 001 当我绘图时 色标自动遵循数据范围 如何设置自定义比例 我不想看到 0 001 的浅色 而应该看到 0 15 的浅色 如何修
  • Python 内置的 super() 是否违反了 DRY?

    显然这是有原因的 但我没有足够的经验来认识到这一点 这是Python中给出的例子docs http docs python org 2 library functions html super class C B def method se
  • 未知错误:Chrome 无法启动:异常退出

    当我使用 chromedriver 对 Selenium 运行测试时 出现此错误 selenium common exceptions WebDriverException Message unknown error Chrome fail

随机推荐