Skip to content

Commit f5c9e19

Browse files
authored
Merge pull request #17609 from tacaswell/auto-backport-of-pr-17602-on-v3.2.x
Backport PR #17602: FIX: propagate _is_saving state when changing can…
2 parents 889c73f + 6afbad4 commit f5c9e19

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/matplotlib/backend_bases.py

+3-2
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

+9
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)