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

Skip to content

Commit c5f8969

Browse files
authored
Merge pull request #17602 from tacaswell/fix_mixed_canvas_animation_save
FIX: propagate _is_saving state when changing canvases
2 parents f820c27 + 81f44f5 commit c5f8969

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
@@ -2084,8 +2084,9 @@ def print_figure(
20842084
# Some code (e.g. Figure.show) differentiates between having *no*
20852085
# manager and a *None* manager, which should be fixed at some point,
20862086
# but this should be fine.
2087-
with cbook._setattr_cm(self, _is_saving=True, manager=None), \
2088-
cbook._setattr_cm(self.figure, dpi=dpi):
2087+
with cbook._setattr_cm(self, manager=None), \
2088+
cbook._setattr_cm(self.figure, dpi=dpi), \
2089+
cbook._setattr_cm(canvas, _is_saving=True):
20892090
origfacecolor = self.figure.get_facecolor()
20902091
origedgecolor = self.figure.get_edgecolor()
20912092

lib/matplotlib/tests/test_figure.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,3 +579,12 @@ def test_tightbbox_box_aspect():
579579
ax2 = fig.add_subplot(gs[0, 1], projection='3d')
580580
ax1.set_box_aspect(.5)
581581
ax2.set_box_aspect((2, 1, 1))
582+
583+
584+
@check_figures_equal(extensions=["svg", "pdf", "eps", "png"])
585+
def test_animated_with_canvas_change(fig_test, fig_ref):
586+
ax_ref = fig_ref.subplots()
587+
ax_ref.plot(range(5))
588+
589+
ax_test = fig_test.subplots()
590+
ax_test.plot(range(5), animated=True)

0 commit comments

Comments
 (0)