Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 171e74a

Browse files
authored
Merge pull request #21758 from greglucas/macosx-fig-draw
FIX: Make sure a renderer gets attached to figure after draw
2 parents fc81ac8 + 8699cc2 commit 171e74a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/matplotlib/backends/backend_macosx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _draw(self):
4343

4444
def draw(self):
4545
# docstring inherited
46-
self.draw_idle()
46+
self._draw()
4747
self.flush_events()
4848

4949
# draw_idle is provided by _macosx.FigureCanvas
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pytest
2+
3+
import matplotlib.pyplot as plt
4+
5+
6+
pytest.importorskip("matplotlib.backends.backend_macosx",
7+
reason="These are mac only tests")
8+
9+
10+
@pytest.mark.backend('macosx')
11+
def test_cached_renderer():
12+
# Make sure that figures have an associated renderer after
13+
# a fig.canvas.draw() call
14+
fig = plt.figure(1)
15+
fig.canvas.draw()
16+
assert fig._cachedRenderer is not None
17+
18+
fig = plt.figure(2)
19+
fig.draw_without_rendering()
20+
assert fig._cachedRenderer is not None

0 commit comments

Comments
 (0)