FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Draggable legend results RuntimeError and AttributeError on Mac OS 10.8.1 · Issue #1266 · matplotlib/matplotlib · GitHub

Repository navigation

Draggable legend results RuntimeError and AttributeError on Mac OS 10.8.1 #1266

Closed

Description

Environment:

  • Python 2.7.3
  • Matplotlib 1.1.1
  • Max OS 10.8.1

Code:

In [1]: import matplotlib.pyplot as plt

In [2]: plt.bar([1, 2, 3], [2, 3, 2], label='label')
Out[2]: 
[<matplotlib.patches.Rectangle at 0x1043415d0>,
 <matplotlib.patches.Rectangle at 0x104341650>,
 <matplotlib.patches.Rectangle at 0x104341ad0>]

In [3]: l = plt.legend()

In [4]: l.draggable()
Out[4]: <matplotlib.legend.DraggableLegend at 0x10434fbd0>

Once I drag the legend, the following errors occurred. The same code works fine in Windows XP.

  File "/Users/sin/Library/Python/2.7/lib/python/site-packages/matplotlib/offsetbox.py", line 376, in get_extent_offsets
    whd_list = [c.get_extent(renderer) for c in self.get_visible_children()]
  File "/Users/sin/Library/Python/2.7/lib/python/site-packages/matplotlib/offsetbox.py", line 639, in get_extent
    "lp", self._text._fontproperties, ismath=False)
  File "/Users/sin/Library/Python/2.7/lib/python/site-packages/matplotlib/backends/backend_macosx.py", line 161, in get_text_width_height_descent
    width, height, descent = self.gc.get_text_width_height_descent(unicode(s), family, size, weight, style)
RuntimeError: CGContextRef is NULL
Traceback (most recent call last):
  File "/Users/sin/Library/Python/2.7/lib/python/site-packages/matplotlib/backend_bases.py", line 1588, in motion_notify_event
    self.callbacks.process(s, event)
  File "/Users/sin/Library/Python/2.7/lib/python/site-packages/matplotlib/cbook.py", line 262, in process
    proxy(*args, **kwargs)
  File "/Users/sin/Library/Python/2.7/lib/python/site-packages/matplotlib/cbook.py", line 188, in __call__
    return mtd(*args, **kwargs)
  File "/Users/sin/Library/Python/2.7/lib/python/site-packages/matplotlib/offsetbox.py", line 1434, in on_motion
    self.update_offset(dx, dy)
  File "/Users/sin/Library/Python/2.7/lib/python/site-packages/matplotlib/offsetbox.py", line 1504, in update_offset
    loc_in_canvas = self.offsetbox_x + dx, self.offsetbox_y + dy
AttributeError: 'DraggableLegend' object has no attribute 'offsetbox_x'

Activity

  1. dmcdougall commented on Sep 17, 2012

    Member

    I can recreate this on 10.7.4.

  2. mdehoon commented on Dec 12, 2012

    Contributor

    The first problem typically occurs when trying to draw outside of the event loop. If so, then the problem may be in the design of the offsetbox.py code. This is a minimal example of this error:

    from pylab import *
    f = figure()
    renderer = f.canvas.renderer
    gc = renderer.new_gc()
    Traceback (most recent call last):
    File "", line 1, in
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 97, in new_gc
    self.gc.save()
    RuntimeError: CGContextRef is NULL

    The gist is that the graphics context gc is not properly initialized outside of the event loop, so you cannot grab a renderer and start drawing to it.

  3. crogre commented on Dec 21, 2012

    I see the same thing with OS X 10.8.2 and matplotlib 1.2.0.

  4. michaelaye commented on Jul 4, 2013

    It works here with:
    10.8.4
    mpl 1.2.1
    Qt4Agg

  5. obtitus commented on Aug 29, 2013

    I believe this is a macosx backend issue. Other backends work fine, but the macosx gives the reported runtime error.

  6. mdehoon commented on Aug 30, 2013

    Contributor

    AFAICT it's not a macosx backend issue, but an issue with offsetbox.py.

  7. tacaswell commented on Aug 30, 2013

    Member

    works fine in linux 1.4.x, 2.7 and Qt4Agg.

    It is pretty clearly in the macosx backend.

  8. mdehoon commented on Sep 3, 2013

    Contributor

    The bug shows up when using the macosx backend. That does not necessarily mean that the bug is located is the macosx backend.

  9. added this to the milestone on Aug 18, 2014
  10. tacaswell commented on Aug 18, 2014

    Member

    This seems to be (as with blitting) an consequence of the quartz not being able to issue draw commands outside of the draw call back.

    Should be linked with #1319 and #531

  11. mdboom commented on Mar 21, 2016

    Member

    Fixed by #6178

  12. modified the milestones: , on Mar 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL