Skip to content

Commit af83578

Browse files
authored
Merge pull request #23174 from oscargus/clabelsubfigures
FIX: Make sure SubFigure has _cachedRenderer
2 parents ac9ccd6 + 4e5019e commit af83578

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
@@ -2060,6 +2060,14 @@ def dpi(self):
20602060
def dpi(self, value):
20612061
self._parent.dpi = value
20622062

2063+
@property
2064+
def _cachedRenderer(self):
2065+
return self._parent._cachedRenderer
2066+
2067+
@_cachedRenderer.setter
2068+
def _cachedRenderer(self, renderer):
2069+
self._parent._cachedRenderer = renderer
2070+
20632071
def _redo_transform_rel_fig(self, bbox=None):
20642072
"""
20652073
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
@@ -585,3 +585,23 @@ def test_all_algorithms():
585585
ax.contourf(x, y, z, algorithm=algorithm)
586586
ax.contour(x, y, z, algorithm=algorithm, colors='k')
587587
ax.set_title(algorithm)
588+
589+
590+
def test_subfigure_clabel():
591+
# Smoke test for gh#23173
592+
delta = 0.025
593+
x = np.arange(-3.0, 3.0, delta)
594+
y = np.arange(-2.0, 2.0, delta)
595+
X, Y = np.meshgrid(x, y)
596+
Z1 = np.exp(-(X**2) - Y**2)
597+
Z2 = np.exp(-((X - 1) ** 2) - (Y - 1) ** 2)
598+
Z = (Z1 - Z2) * 2
599+
600+
fig = plt.figure()
601+
figs = fig.subfigures(nrows=1, ncols=2)
602+
603+
for f in figs:
604+
ax = f.subplots()
605+
CS = ax.contour(X, Y, Z)
606+
ax.clabel(CS, inline=True, fontsize=10)
607+
ax.set_title("Simplest default with labels")

0 commit comments

Comments
 (0)
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