Comments (5)
Here's some workarounds:
-
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).
-
If you want to add a single artist, wouldn't a call to subplot.add_artist() suffice?
from matplotlib.
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.
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.
@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.
This is the same problem as #2654 and #1266 closing as we have those still open.
from matplotlib.
Related Issues (20)
- Version number of "FreeType" in matplotlib 3.5.2 HOT 2
- [ENH]: Add fill between support for 3D plots HOT 3
- [TST] Upcoming dependency test failures
- [Bug]: Useless recursive group in SVG output when using path_effects HOT 4
- [ENH]: Fonts searching logic HOT 3
- [ENH]: callable color map of Plasma with Deuteranopia colourblind filter HOT 3
- [Bug]: incorrect placement of superscripts on large delimiters HOT 1
- [MNT]: Make the colormap naming work with any capitalization
- [Bug]: GridSpec do not type check as Iterable in zip HOT 7
- [ENH]: Add an easy way to plot an infinite half space (e.g. with a HalfSpace patch)
- [Bug]: rcParams["axes.labelcolor"] treats "none" and "None" differently
- [MNT]: Inconsistent use of "inherit" and "auto" for color fallback in rcParams HOT 3
- [ENH]: axes.labelcolor should use text.color by default HOT 3
- [ENH]: Automatically trim the time on the x axis HOT 20
- [Bug]: Pyplot internal bug HOT 1
- [Bug]: PolygonSelector should hide itself when zoom/pan is active HOT 6
- [Bug]: Removing tools from the toolmanager that are not on the toolbar triggers an exception
- [TST] Upcoming dependency test failures
- [Doc]: `get_figure` may return a `SubFigure` HOT 7
- [ENH]: Make the font family "Computer Modern" more accessible HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matplotlib.