8000 Backport PR #17602: FIX: propagate _is_saving state when changing can… by tacaswell · Pull Request #17609 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #17602: FIX: propagate _is_saving state when changing can… #17609

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
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
5 changes: 3 additions & 2 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2068,8 +2068,9 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None,
# Some code (e.g. Figure.show) differentiates between having *no*
# manager and a *None* manager, which should be fixed at some point,
# but this should be fine.
with cbook._setattr_cm(self, _is_saving=True, manager=None), \
cbook._setattr_cm(self.figure, dpi=dpi):
with cbook._setattr_cm(self, manager=None), \
cbook._setattr_cm(self.figure, dpi=dpi), \
cbook._setattr_cm(canvas, _is_saving=True):

if facecolor is None:
facecolor = rcParams['savefig.facecolor']
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,3 +487,12 @@ def test_removed_axis():
fig, axs = plt.subplots(2, sharex=True)
axs[0].remove()
fig.canvas.draw()


@check_figures_equal(extensions=["svg", "pdf", "eps", "png"])
def test_animated_with_canvas_change(fig_test, fig_ref):
ax_ref = fig_ref.subplots()
ax_ref.plot(range(5))

ax_test = fig_test.subplots()
ax_test.plot(range(5), animated=True)
0