8000 Backport PR #17602: FIX: propagate _is_saving state when changing can… · QuLogic/matplotlib@6afbad4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6afbad4

Browse files
QuLogictacaswell
authored andcommitted
Backport PR matplotlib#17602: FIX: propagate _is_saving state when changing canvases
Merge pull request matplotlib#17602 from tacaswell/fix_mixed_canvas_animation_save FIX: propagate _is_saving state when changing canvases Conflicts: lib/matplotlib/backend_bases.py - other nearby changes, only backport the context manager related changes lib/matplotlib/tests/test_figure.py - did not backport the other tests that are currently only on master branch.
1 parent 889c73f commit 6afbad4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,8 +2068,9 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
20682068
# Some code (e.g. Figure.show) differentiates between having *no*
20692069
# manager and a *None* manager, which should be fixed at some point,
20702070
# but this should be fine.
2071-
with cbook._setattr_cm(self, _is_saving=True, manager=None), \
2072-
cbook._setattr_cm(self.figure, dpi=dpi):
2071+
with cbook._setattr_cm(self, manager=None), \
2072+
cbook._setattr_cm(self.figure, dpi=dpi), \
2073+
cbook._setattr_cm(canvas, _is_saving=True):
20732074

20742075
if facecolor is None:
20752076
facecolor = rcParams['savefig.facecolor']

lib/matplotlib/tests/test_figure.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,3 +487,12 @@ def test_removed_axis():
487487
fig, axs = plt.subplots(2, sharex=True)
488488
axs[0].remove()
489489
fig.canvas.draw()
490+
491+
492+
@check_figures_equal(extensions=["svg", "pdf", "eps", "png"])
493+
def test_animated_with_canvas_change(fig_test, fig_ref):
494+
ax_ref = fig_ref.subplots()
495+
ax_ref.plot(range(5))
496+
497+
ax_test = fig_test.subplots()
498+
ax_test.plot(range(5), animated=True)

0 commit comments

Comments
 (0)
0