[Matplotlib-devel] Confusion about draw_artist
Matthew Brett
matthew.brett at gmail.com
Wed Nov 30 14:10:32 EST 2016
Hi,
We're using 'draw_artist' in an image viewer, and I just found that
our viewer is crashing using the macosx backend. Here's a minimal
example:
import matplotlib
matplotlib.use('macosx')
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1)
im = plt.imshow([[1, 2], [3, 4]])
fig.canvas.draw()
ax.draw_artist(im)
This generates:
Traceback (most recent call last):
File "draw_artist.py", line 8, in <module>
ax.draw_artist(im)
File "/Users/mb312/dev_trees/matplotlib/lib/matplotlib/axes/_base.py",
line 2423, in draw_artist
raise AttributeError(msg)
AttributeError: draw_artist can only be used after an initial draw
which caches the render
for the macosx backend, and works correctly for the tkagg backend.
I can't see any way to cache the renderer here - could someone give me
a pointer?
Cheers,
Matthew
More information about the Matplotlib-devel
mailing list