Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xkcd plots stopped working on Mac OS X. #5049

Closed
mario-grgic opened this issue Sep 11, 2015 · 6 comments · Fixed by #5217
Closed

xkcd plots stopped working on Mac OS X. #5049

mario-grgic opened this issue Sep 11, 2015 · 6 comments · Fixed by #5217
Assignees
Milestone

Comments

@mario-grgic
Copy link

The matplotlib xkcd example plots at

http://matplotlib.org/examples/showcase/xkcd.html

stopped working with matplotlib 1.4.x (they used to work with earlier versions). This is with Python 2.7.5 on Mac OS X 10.9.5 and matplotlib 1.4.3.

The following Traceback is printed if I run one of the examples:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 1085, in draw
    func(*args)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/axes/_base.py", line 2110, in draw
    a.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/lines.py", line 715, in draw
    drawFunc(renderer, gc, tpath, affine.frozen())
  File "/Library/Python/2.7/site-packages/matplotlib/lines.py", line 1072, in _draw_lines
    self._lineFunc(renderer, gc, path, trans)
  File "/Library/Python/2.7/site-packages/matplotlib/lines.py", line 1112, in _draw_solid
    renderer.draw_path(gc, path, trans)
  File "/Library/Python/2.7/site-packages/matplotlib/patheffects.py", line 115, in draw_path
    rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib/patheffects.py", line 217, in draw_path
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.py", line 58, in draw_path
    gc.draw_path(path, transform, linewidth, rgbFace)
AttributeError: GraphicsContextBase instance has no attribute 'draw_path'
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 1085, in draw
    func(*args)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/axes/_base.py", line 2110, in draw
    a.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 1119, in draw
    tick.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/axis.py", line 244, in draw
    self.tick1line.draw(renderer)
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/lines.py", line 760, in draw
    rgbaFace)
  File "/Library/Python/2.7/site-packages/matplotlib/patheffects.py", line 127, in draw_markers
    **kwargs)
  File "/Library/Python/2.7/site-packages/matplotlib/backend_bases.py", line 265, in draw_markers
    rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib/patheffects.py", line 115, in draw_path
    rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib/patheffects.py", line 217, in draw_path
    renderer.draw_path(gc, tpath, affine, rgbFace)
  File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.py", line 58, in draw_path
    gc.draw_path(path, transform, linewidth, rgbFace)
AttributeError: GraphicsContextBase instance has no attribute 'draw_path'
@mdboom
Copy link
Member

mdboom commented Sep 11, 2015

Seems to be specific to the macosx backed. Cc: @mdehoon

@mdehoon
Copy link
Contributor

mdehoon commented Sep 11, 2015

Why, on line 217 in patheffects.py, is renderer.draw_path(gc, ...) being called on a RendererMac object while gc is a GraphicsContextBase instead of a GraphicsContextMac? I suspect a call to

        # Get the real renderer, not a PathEffectRenderer.
        if isinstance(renderer, PathEffectRenderer):
            renderer = renderer._renderer

is missing, but it may be some deeper problem.

@tacaswell
Copy link
Member

Is this related to #4024 ?

@tacaswell tacaswell added this to the proposed next point release milestone Sep 12, 2015
@mdehoon
Copy link
Contributor

mdehoon commented Sep 14, 2015

@tacaswell I think what we are seeing here is a more fundamental issue. If we solve this one then #4024 will likely also be solved; the opposite is not true though.

@mdehoon
Copy link
Contributor

mdehoon commented Oct 5, 2015

The equivalent bug appears with the gtkcairo backend:

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-0_unknown-py2.7-macosx-10.9-intel.egg/matplotlib/backends/backend_cairo.py", line 153, in draw_path
    ctx = gc.ctx
AttributeError: 'GraphicsContextBase' object has no attribute 'ctx'

The origin of the bug is the same: The gtkcairo renderer is used with a generic (GraphicsContextBase) graphics context instead of a GraphicsContextCairo graphics context.

@mdehoon
Copy link
Contributor

mdehoon commented Oct 9, 2015

Also broken in the same way with the GTK backend:

AttributeError: 'GraphicsContextBase' object has no attribute 'gdkGC'

and with the ps backend:

AttributeError: 'GraphicsContextBase' object has no attribute 'shouldstroke'

@mdboom mdboom modified the milestones: next point release (1.5.0), proposed next point release (2.1) Oct 9, 2015
@mdboom mdboom self-assigned this Oct 9, 2015
mdboom added a commit to mdboom/matplotlib that referenced this issue Oct 9, 2015
The special sub-GC that is created by the PathEffectRenderer was of
GraphicsContextBase, rather than the backend-specific GC.

Fix matplotlib#5049, Fix matplotlib#4024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants