From 81f44f5692650423d1f13ac277b8ae987e7e337d Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 9 Jun 2020 18:27:24 -0400 Subject: [PATCH] FIX: propagate _is_saving state when changing canvases We have logic to draw animated artists if we are rendering due to savefig (as opposed to rendering to put into a GUI). Not every canvas class can write every format so we can switch the canvas as save time based on the requested extension / format. Make sure we set the sate on the canvas we are actually using to save the figure rather than the canvas that is attached to the figure when we start saving. closes #17599 --- lib/matplotlib/backend_bases.py | 5 +++-- lib/matplotlib/tests/test_figure.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 1d72b1fcefca..bc540dee940a 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2073,8 +2073,9 @@ def print_figure( # 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): origfacecolor = self.figure.get_facecolor() origedgecolor = self.figure.get_edgecolor() diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index 5d508db78e7b..36f0c2f76ca0 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -579,3 +579,12 @@ def test_tightbbox_box_aspect(): ax2 = fig.add_subplot(gs[0, 1], projection='3d') ax1.set_box_aspect(.5) ax2.set_box_aspect((2, 1, 1)) + + +@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) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy