8000 Merge pull request #28479 from rcomer/v3.9.x · fedora-python/matplotlib@24e3013 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 24e3013

Browse files
authored
Merge pull request matplotlib#28479 from rcomer/v3.9.x
Backport PR matplotlib#28397 (FIX: stale root Figure when adding/updating subfigures)
2 parents 826575f + bbb0d01 commit 24e3013

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/matplotlib/figure.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,8 @@ def add_subfigure(self, subplotspec, **kwargs):
16331633
sf = SubFigure(self, subplotspec, **kwargs)
16341634
self.subfigs += [sf]
16351635
sf._remove_method = self.subfigs.remove
1636+
sf.stale_callback = _stale_figure_callback
1637+
self.stale = True
16361638
return sf
16371639

16381640
def sca(self, a):

lib/matplotlib/tests/test_figure.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,3 +1733,27 @@ def test_warn_colorbar_mismatch():
17331733
subfig3_1.colorbar(im3_2) # should not warn
17341734
with pytest.warns(UserWarning, match="different Figure"):
17351735
subfig3_1.colorbar(im4_1)
1736+
1737+
1738+
def test_subfigure_stale_propagation():
1739+
fig = plt.figure()
1740+
1741+
fig.draw_without_rendering()
1742+
assert not fig.stale
1743+
1744+
sfig1 = fig.subfigures()
1745+
assert fig.stale
1746+
1747+
fig.draw_without_rendering()
1748+
assert not fig.stale
1749+
assert not sfig1.stale
1750+
1751+
sfig2 = sfig1.subfigures()
1752+
assert fig.stale
1753+
1754+
fig.draw_without_rendering()
1755+
assert not fig.stale
1756+
assert not sfig2.stale
1757+
1758+
sfig2.stale = True
1759+
assert fig.stale

0 commit comments

Comments
 (0)
0