Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit e163a0b

Browse files
Merge pull request #23184 from tacaswell/auto-backport-of-pr-23174-on-v3.5.x
Backport PR #23174: Make sure SubFigure has _cachedRenderer
2 parents bcd72f8 + 92d8bf0 commit e163a0b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

‎lib/matplotlib/figure.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,14 @@ def dpi(self):
20822082
def dpi(self, value):
20832083
self._parent.dpi = value
20842084

2085+
@property
2086+
def _cachedRenderer(self):
2087+
return self._parent._cachedRenderer
2088+
2089+
@_cachedRenderer.setter
2090+
def _cachedRenderer(self, renderer):
2091+
self._parent._cachedRenderer = renderer
2092+
20852093
def _redo_transform_rel_fig(self, bbox=None):
20862094
"""
20872095
Make the transSubfigure bbox relative to Figure transform.

‎lib/matplotlib/tests/test_contour.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,3 +520,23 @@ def test_contour_autolabel_beyond_powerlimits():
520520
ax.clabel(cs)
521521
# Currently, the exponent is missing, but that may be fixed in the future.
522522
assert {text.get_text() for text in ax.texts} == {"0.25", "1.00", "4.00"}
523+
524+
525+
def test_subfigure_clabel():
526+
# Smoke test for gh#23173
527+
delta = 0.025
528+
x = np.arange(-3.0, 3.0, delta)
529+
y = np.arange(-2.0, 2.0, delta)
530+
X, Y = np.meshgrid(x, y)
531+
Z1 = np.exp(-(X**2) - Y**2)
532+
Z2 = np.exp(-((X - 1) ** 2) - (Y - 1) ** 2)
533+
Z = (Z1 - Z2) * 2
534+
535+
fig = plt.figure()
536+
figs = fig.subfigures(nrows=1, ncols=2)
537+
538+
for f in figs:
539+
ax = f.subplots()
540+
CS = ax.contour(X, Y, Z)
541+
ax.clabel(CS, inline=True, fontsize=10)
542+
ax.set_title("Simplest default with labels")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /