Skip to content

Commit 6af9062

Browse files
committed
Add note on incompatibility with blitting of widgets
1 parent 545892a commit 6af9062

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

doc/release/next_whats_new/pyplot-register-figure.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ general, you should not store a reference to the canvas, but rather always
5858
obtain it from the figure with ``fig.canvas``. This will return the current
5959
canvas, which is either the original `.FigureCanvasBase` or a backend-dependent
6060
subclass, depending on whether the figure is registered with pyplot or not.
61+
Additionally, the swapping of the canvas currently does not play well with
62+
blitting of matplotlib widgets; in such cases either deactivate blitting or do not
63+
continue to use the figure (e.g. saving it after closing the window).

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import matplotlib as mpl
2020
from matplotlib import _c_internal_utils
21+
from matplotlib.backend_bases import FigureCanvasBase
2122
from matplotlib.backend_tools import ToolToggleBase
2223
from matplotlib.testing import subprocess_run_helper as _run_helper, is_ci_environment
2324

@@ -229,6 +230,7 @@ def check_alt_backend(alt_backend):
229230

230231
# When the figure is closed, it's manager is removed and the canvas is reset to
231232
# FigureCanvasBase. Saving should still be possible.
233+
assert type(fig.canvas) == FigureCanvasBase
232234
result_after = io.BytesIO()
233235
fig.savefig(result_after, format='png', dpi=100)
234236

0 commit comments

Comments
 (0)