Skip to content

Navigation Menu

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 d347c32

Browse filesBrowse files
authored
Merge pull request #28397 from rcomer/subfigure-stale
FIX: stale root Figure when adding/updating subfigures
2 parents 664b457 + 2ce8941 commit d347c32
Copy full SHA for d347c32

File tree

2 files changed

+26
-0
lines changed
Filter options

2 files changed

+26
-0
lines changed

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,8 @@ def add_subfigure(self, subplotspec, **kwargs):
16361636
sf = SubFigure(self, subplotspec, **kwargs)
16371637
self.subfigs += [sf]
16381638
sf._remove_method = self.subfigs.remove
1639+
sf.stale_callback = _stale_figure_callback
1640+
self.stale = True
16391641
return sf
16401642

16411643
def sca(self, a):

‎lib/matplotlib/tests/test_figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_figure.py
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,3 +1741,27 @@ def test_subfigure_row_order():
17411741
sf_arr = fig.subfigures(4, 3)
17421742
for a, b in zip(sf_arr.ravel(), fig.subfigs):
17431743
assert a is b
1744+
1745+
1746+
def test_subfigure_stale_propagation():
1747+
fig = plt.figure()
1748+
1749+
fig.draw_without_rendering()
1750+
assert not fig.stale
1751+
1752+
sfig1 = fig.subfigures()
1753+
assert fig.stale
1754+
1755+
fig.draw_without_rendering()
1756+
assert not fig.stale
1757+
assert not sfig1.stale
1758+
1759+
sfig2 = sfig1.subfigures()
1760+
assert fig.stale
1761+
1762+
fig.draw_without_rendering()
1763+
assert not fig.stale
1764+
assert not sfig2.stale
1765+
1766+
sfig2.stale = True
1767+
assert fig.stale

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.