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

Appearance settings

Commit 14711fa

Browse filesBrowse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #28465: Fix pickling of SubFigures
1 parent 1f0e4c4 commit 14711fa
Copy full SHA for 14711fa

File tree

3 files changed

+11
-2
lines changed
Filter options

3 files changed

+11
-2
lines changed

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,6 @@ def __init__(self, parent, subplotspec, *,
22242224
self.subplotpars = parent.subplotpars
22252225
self.dpi_scale_trans = parent.dpi_scale_trans
22262226
self._axobservers = parent._axobservers
2227-
self.canvas = parent.canvas
22282227
self.transFigure = parent.transFigure
22292228
self.bbox_relative = Bbox.null()
22302229
self._redo_transform_rel_fig()
@@ -2241,6 +2240,10 @@ def __init__(self, parent, subplotspec, *,
22412240
self._set_artist_props(self.patch)
22422241
self.patch.set_antialiased(False)
22432242

2243+
@property
2244+
def canvas(self):
2245+
return self._parent.canvas
2246+
22442247
@property
22452248
def dpi(self):
22462249
return self._parent.dpi

‎lib/matplotlib/figure.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.pyi
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ class SubFigure(FigureBase):
263263
figure: Figure
264264
subplotpars: SubplotParams
265265
dpi_scale_trans: Affine2D
266-
canvas: FigureCanvasBase
267266
transFigure: Transform
268267
bbox_relative: Bbox
269268
figbbox: BboxBase
@@ -282,6 +281,8 @@ class SubFigure(FigureBase):
282281
**kwargs
283282
) -> None: ...
284283
@property
284+
def canvas(self) -> FigureCanvasBase: ...
285+
@property
285286
def dpi(self) -> float: ...
286287
@dpi.setter
287288
def dpi(self, value: float) -> None: ...

‎lib/matplotlib/tests/test_pickle.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_pickle.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ def _generate_complete_test_figure(fig_ref):
9393
plt.errorbar(x, x * -0.5, xerr=0.2, yerr=0.4, label='$-.5 x$')
9494
plt.legend(draggable=True)
9595

96+
# Ensure subfigure parenting works.
97+
subfigs = fig_ref.subfigures(2)
98+
subfigs[0].subplots(1, 2)
99+
subfigs[1].subplots(1, 2)
100+
96101
fig_ref.align_ylabels() # Test handling of _align_label_groups Groupers.
97102

98103

0 commit comments

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