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

Skip to content

Backport PR #21758 on branch v3.5.x (FIX: Make sure a renderer gets attached to figure after draw) #21777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _draw(self):

def draw(self):
# docstring inherited
self.draw_idle()
self._draw()
self.flush_events()

# draw_idle is provided by _macosx.FigureCanvas
Expand Down
20 changes: 20 additions & 0 deletions lib/matplotlib/tests/test_backend_macosx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

import matplotlib.pyplot as plt


pytest.importorskip("matplotlib.backends.backend_macosx",
reason="These are mac only tests")


@pytest.mark.backend('macosx')
def test_cached_renderer():
# Make sure that figures have an associated renderer after
# a fig.canvas.draw() call
fig = plt.figure(1)
fig.canvas.draw()
assert fig._cachedRenderer is not None

fig = plt.figure(2)
fig.draw_without_rendering()
assert fig._cachedRenderer is not None