From 2ce894113215d1b6c897b99d3e91bd03cd8dcfe1 Mon Sep 17 00:00:00 2001 From: Ruth Comer <10599679+rcomer@users.noreply.github.com> Date: Thu, 13 Jun 2024 20:20:53 +0100 Subject: [PATCH] FIX: stale root Figure when adding/updating subfigures --- lib/matplotlib/figure.py | 2 ++ lib/matplotlib/tests/test_figure.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 9139b2ed262f..9f764cc2332f 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1636,6 +1636,8 @@ def add_subfigure(self, subplotspec, **kwargs): sf = SubFigure(self, subplotspec, **kwargs) self.subfigs += [sf] sf._remove_method = self.subfigs.remove + sf.stale_callback = _stale_figure_callback + self.stale = True return sf def sca(self, a): diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index e8edcf61815d..5a8894b10496 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -1741,3 +1741,27 @@ def test_subfigure_row_order(): sf_arr = fig.subfigures(4, 3) for a, b in zip(sf_arr.ravel(), fig.subfigs): assert a is b + + +def test_subfigure_stale_propagation(): + fig = plt.figure() + + fig.draw_without_rendering() + assert not fig.stale + + sfig1 = fig.subfigures() + assert fig.stale + + fig.draw_without_rendering() + assert not fig.stale + assert not sfig1.stale + + sfig2 = sfig1.subfigures() + assert fig.stale + + fig.draw_without_rendering() + assert not fig.stale + assert not sfig2.stale + + sfig2.stale = True + assert fig.stale 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