Git Product home page Git Product logo

Comments (5)

dmcdougall avatar dmcdougall commented on May 13, 2024

Here's some workarounds:

  1. Instead of calling plt.draw() to draw the whole figure. One can call plt.gca() to clear the axis, and then add the updated image to the axis with a call to plt.imshow(blah).

  2. If you want to add a single artist, wouldn't a call to subplot.add_artist() suffice?

from matplotlib.

pelson avatar pelson commented on May 13, 2024

Looks like the original issue was @rougier. If you remember the scenario, would you be able to provide some more information (re @mdehoon and @dmcdougall 's questions). Thanks.

from matplotlib.

rougier avatar rougier commented on May 13, 2024

What do you mean by scenario ? If this is the original animation file, I'm not sure I still have the code.

For the original code, I think I use the one from http://www.scipy.org/Cookbook/Matplotlib/Animations (Animating selected plot elements)

from matplotlib.

astrofrog avatar astrofrog commented on May 13, 2024

@dmcdougall @pelson - I am running into the same issue with the following code:

import numpy as np

import matplotlib
matplotlib.use('MacOSX')
from matplotlib import pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
image = ax.imshow(np.random.random((128, 128)))
def test_callback(event):
    ax.draw_artist(image)
fig.canvas.mpl_connect('button_press_event', test_callback)
plt.show()

If I click anywhere in the axes (to trigger the callback) I get:

Traceback (most recent call last):
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/backend_bases.py", line 1785, in button_press_event
    self.callbacks.process(s, mouseevent)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/cbook.py", line 527, in process
    proxy(*args, **kwargs)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/cbook.py", line 405, in __call__
    return mtd(*args, **kwargs)
  File "test_draw_artist.py", line 11, in test_callback
    ax.draw_artist(image)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/axes.py", line 2098, in draw_artist
    a.draw(self._cachedRenderer)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/artist.py", line 54, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/image.py", line 352, in draw
    gc = renderer.new_gc()
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.6-x86_64.egg/matplotlib/backends/backend_macosx.py", line 97, in new_gc
    self.gc.save()
RuntimeError: CGContextRef is NULL

This is specific to the MacOSX backend.

from matplotlib.

tacaswell avatar tacaswell commented on May 13, 2024

This is the same problem as #2654 and #1266 closing as we have those still open.

from matplotlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.