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 上运行 的相关文章

  • 按键合并的两个字典的值的并集

    我有两本词典 d1 a x y b k l d2 a m n c p r 如何合并这两个字典以获得这样的结果 d3 a x y m n b k l c p r 当字典的值是简单类型 如 int 或 str 时 这有效 d3 dict i a
  • 使用plot(...,add=T) 叠加栅格图会导致最终图任意错位

    我发现 当我尝试使用plot add T 叠加多个栅格时 如果我尝试将超过3 个栅格叠加在一起 则后续图不会正确对齐栅格 我的初衷是创建一个模拟土地覆盖的分类地图 其中代表覆盖类别的颜色深浅随着我们模型投影的确定性而变化 为此 我创建了一个
  • 字符串的 gnuplot 图

    是否可以传递字符串中的绘图数据 我的意思是做这样的事情 plot 09 13 2010 2263 80 09 14 2010 2500 using 1 2 with lines 可以做类似的事情 set xdata time set tim
  • Python 2.7 中四舍五入到小数点后两位?

    使用Python 2 7如何将我的数字四舍五入到小数点后两位而不是它给出的10位左右 print financial return of outcome 1 str out1 使用内置函数round https docs python or
  • Tornado 和 WTForms

    我是第一次使用 WTForms 使用 WTForms 验证 Tornado 中的 POST 请求 以下是我的表格 表格 py class UserForm Form user TextField user validators Length
  • 有没有办法降低 scipy/numpy 精度以减少内存消耗?

    在我的 64 位 Debian Lenny 系统 4GByte RAM 4GByte 交换分区 上 我可以成功执行以下操作 v array 10000 random 512 512 512 dtype np int16 f fftn v 但
  • 根据三列中的值组织行

    导入并获取数据集import numpy as np import matplotlib pyplot as plt import pandas as pd df pd DataFrame DaysExperienceTask 7 8 2
  • Python argparse:需要两个并存的位置参数

    使用 argparse 如何指定我希望两个位置参数一起出现或根本不出现 IE 我希望我的使用字符串看起来像 Usage FooBar py h FOO BAR 正如 hpaulj 所建议的 这是您可以使用的解决方案 In 1 import
  • Matplotlib 颤抖比例

    我正在尝试使用 matplotlib 和 quiver 函数绘制一些箭头 但我想使用数组单独选择每个箭头的长度 http matplotlib sourceforge net api pyplot api html matplotlib p
  • Theano导入错误

    我正在尝试在 CPU 机器上安装 Theano 运行 intel HD 显卡 没有 NVIDIA 在 python 中测试时出现以下导入错误 WARNING theano configdefaults g not detected Thea
  • 类型错误:“生成器”对象没有属性“__getitem__”

    我编写了一个应该返回字典的生成函数 但是当我尝试打印字段时出现以下错误 print row2 SearchDate TypeError generator object has no attribute getitem 这是我的代码 fro
  • imshow 如何处理具有 M x N x 4 输入的 alpha 通道?

    生长激素问题 3343 http github com matplotlib matplotlib issues 3343 我正在使用imshowmatplotlib 中的函数可可视化一些数据 我有两个数组 A and B 它们的大小相同
  • 为什么我无法从多处理队列中捕获 Queue.Empty 异常?

    我试图捕获 multiprocessing Queue 为空时引发的 Queue Empty 异常 以下不起作用 import multiprocessing f multiprocessing Queue try f get True 0
  • 在 python 中 pickling 数据时出现内存错误

    我正在尝试使用 python 中提供的 dump 命令将字典转储为 pickle 格式 字典的文件大小约为 150 mb 但仅转储 115 mb 的文件时会出现异常 例外情况是 Traceback most recent call last
  • ggplot 中跨组的连续线

    我有一个数据时间序列 其中观察了一些数据 模拟了一些数据 我想生成整个数据系列随时间变化的图 其中颜色表示数据源 但是 我只能弄清楚如何使 ggplot 中的 geom line 连接同一组中的点 这是一个例子来说明 Create samp
  • Python从int到string的快速转换

    我正在用 python 求解大量阶乘 并发现当我完成计算阶乘时 需要相同的时间才能转换为字符串以保存到文件中 我试图找到一种将 int 转换为字符串的快速方法 我将举一个计算和 int 转换时间的例子 我正在使用通用的 a str a 但感
  • 为什么我的代码不能根据字典解码加密字符串?

    我有一本字典 其中包含代表字母的键和值 例如一个简单的 DICT CODE b g n a p o x d t y 我收到了一个加密代码 并将该字符串转换为一个列表 其中每个项目都是一个单词 我需要根据字典中的项目来解决它 代码示例是 wo
  • PyMC3-自定义 theano Op 进行数值积分

    我使用 PyMC3 进行参数估计 使用必须定义的特定似然函数 我用谷歌搜索了一下 发现我应该使用densitydist实现用户定义的似然函数的方法 但它不起作用 如何在 PyMC3 中合并用户定义的似然函数并找出最大 aposteriori
  • 将文本注释到轴并对齐为圆

    我正在尝试在轴上绘制文本并将该文本与圆对齐 更准确地说 有一些具有不同坐标 x y 的点位于该圆内 并使用以下命令创建 ax scatter x y s 100 我想用圆圈连接并标记每个点 Cnameb 文本的坐标由 xp yp 定义 因此
  • 如何将回溯/sys.exc_info() 值保存在变量中?

    我想将错误名称和回溯详细信息保存到变量中 这是我的尝试 import sys try try print x except Exception ex raise NameError except Exception er print 0 s

随机推荐