Skip to content

examples/cursor.py gives RuntimeError on mac osx #3708

Closed

Description

@ifmihai

I ran cursor.py, downloaded from the matplotlib/examples/widgets web page.

I'm on mac osx 10.9.4, anaconda latest as of today, matplotlib 1.3.1

the output is this:

79-118-141-238:wigets ifmichael$ python cursor.py
Traceback (most recent call last):
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/figure.py", line 1040, in draw
    self.canvas.draw_event(renderer)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1693, in draw_event
    self.callbacks.process(s, event)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 527, in process
    proxy(*args, **kwargs)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 405, in __call__
    return mtd(*args, **kwargs)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/widgets.py", line 865, in clear
    self.background = self.canvas.copy_from_bbox(self.ax.bbox)
AttributeError: 'FigureCanvasMac' object has no attribute 'copy_from_bbox'
Traceback (most recent call last):
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1834, in motion_notify_event
    self.callbacks.process(s, event)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 527, in process
    proxy(*args, **kwargs)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 405, in __call__
    return mtd(*args, **kwargs)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/widgets.py", line 892, in onmove
    self._update()
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/widgets.py", line 899, in _update
    self.ax.draw_artist(self.linev)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/axes.py", line 2098, in draw_artist
    a.draw(self._cachedRenderer)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/lines.py", line 526, in draw
    gc = renderer.new_gc()
  File "/Users/ifmichael/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 97, in new_gc
    self.gc.save()
RuntimeError: CGContextRef is NULL

Maybe this issue was resolved in 1.4.0, but I cannot install it (see #3517)

Activity

  1. mdboom commented on Oct 23, 2014

    @mdboom
    Member
  2. mdehoon commented on Oct 24, 2014

    @mdehoon
    Contributor

    Essentially the same issue as #531 . The _update method in lib/matplotlib/widgets.py tries to draw to the canvas directly, rather than through the draw callback (i.e. figure.draw(renderer)). To solve this, the _update method should call draw_if_interactive, which will trigger a call to figure.draw(renderer). This may need some redesign of the copy_from_bbox, restore_region, blit code, but that would be a good thing anyway as it would help towards solving the long-standing issues with the animations code.

  3. WeatherGod commented on Oct 24, 2014

    @WeatherGod
    Member

    Makes me glad I have not included the cursor widget into my book yet...

    On Thu, Oct 23, 2014 at 9:12 PM, mdehoon notifications@github.com wrote:

    Essentially the same issue as #531
    #531 . The _update
    method in lib/matplotlib/widgets.py tries to draw to the canvas directly,
    rather than through the draw callback (i.e. figure.draw(renderer)). To
    solve this, the _update method should call draw_if_interactive, which will
    trigger a call to figure.draw(renderer). This may need some redesign of the
    copy_from_bbox, restore_region, blit code, but that would be a good thing
    anyway as it would help towards solving the long-standing issues with the
    animations code.

    —
    Reply to this email directly or view it on GitHub
    #3708 (comment)
    .

  4. tacaswell commented on Oct 24, 2014

    @tacaswell
    Member

    @WeatherGod The cursor works fine on all of the other backends, I think this is just an macosx issue.

  5. added this to the v1.4.x milestone on Oct 24, 2014
  6. WeatherGod commented on Oct 24, 2014

    @WeatherGod
    Member

    Right, but what is the default backend when installing matplotlib on Macs?
    (I honestly don't know, I am assuming it is the macosx backend).

    On Fri, Oct 24, 2014 at 11:16 AM, Thomas A Caswell <notifications@github.com

    wrote:

    @WeatherGod https://github.com/WeatherGod The cursor works fine on all
    of the other backends, I think this is just an macosx issue.

    —
    Reply to this email directly or view it on GitHub
    #3708 (comment)
    .

  7. jenshnielsen commented on Oct 24, 2014

    @jenshnielsen
    Member

    @WeatherGod Yes on my mac the default backend is OS X

  8. mdehoon commented on Oct 25, 2014

    @mdehoon
    Contributor

    @tacaswell While the issue only appears in the Mac OS X backend, the bug is actually in the widgets.py code.

  9. modified the milestones: , v1.4.x on Feb 7, 2015
  10. jradavenport commented on Mar 13, 2015

    @jradavenport

    Seems like this is a long-standing issue... is the only workaround to force people to use a different backend? (e.g. u'Qt4Agg', u'TkAgg')

  11. dopplershift commented on Oct 24, 2017

    @dopplershift
    Contributor

    This is working fine for me on 2.1 (and also works on 2.0.2) with Python 3.6. I bet this was fixed with #6178.

    Feel free to re-open if someone is able to reproduce.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions