@@ -1472,8 +1472,11 @@ def subfigures(self, nrows=1, ncols=1, squeeze=True,
1472
1472
width_ratios = None , height_ratios = None ,
1473
1473
** kwargs ):
1474
1474
"""
1475
- Add a subfigure to this figure or subfigure. A subfigure has the same
1476
- artist methods as a figure, and is logically the same as a figure.
1475
+ Add a subfigure to this figure or subfigure.
1476
+
1477
+ A subfigure has the same artist methods as a figure, and is logically
1478
+ the same as a figure, but cannot print itself.
1479
+ See :doc:`/gallery/subplots_axes_and_figures/subfigures`.
1477
1480
1478
1481
Parameters
1479
1482
----------
@@ -2056,6 +2059,7 @@ def __init__(self, parent, subplotspec, *,
2056
2059
facecolor = facecolor , edgecolor = edgecolor , linewidth = linewidth ,
2057
2060
# Don't let the figure patch influence bbox calculation.
2058
2061
in_layout = False , transform = self .transSubfigure )
2062
+ self ._set_artist_props (self .patch )
2059
2063
self .patch .set_antialiased (False )
2060
2064
2061
2065
if parent ._layoutgrid is not None :
@@ -2094,12 +2098,13 @@ def _redo_transform_rel_fig(self, bbox=None):
2094
2098
heightf = np .sum (hr [self ._subplotspec .rowspan ]) / np .sum (hr )
2095
2099
2096
2100
x0 = 0
2097
- if self ._subplotspec .colspan [ 0 ] > 0 :
2098
- x0 += np .sum (wr [self ._subplotspec .colspan [ 0 ] - 1 ]) / np .sum (wr )
2101
+ if not self ._subplotspec .is_first_col () :
2102
+ x0 += np .sum (wr [self ._subplotspec .colspan . start - 1 ]) / np .sum (wr )
2099
2103
2100
2104
y0 = 0
2101
- if self ._subplotspec .rowspan [- 1 ] < nrows - 1 :
2102
- y0 += 1 - np .sum (hr [self ._subplotspec .rowspan [- 1 ]- 1 ]) / np .sum (hr )
2105
+ if not self ._subplotspec .is_last_row ():
2106
+ y0 += 1 - (np .sum (hr [self ._subplotspec .rowspan .end - 1 ]) /
2107
+ np .sum (hr ))
2103
2108
2104
2109
if self .bbox_relative is None :
2105
2110
self .bbox_relative = Bbox .from_bounds (x0 , y0 , widthf , heightf )
@@ -2108,9 +2113,27 @@ def _redo_transform_rel_fig(self, bbox=None):
2108
2113
self .bbox_relative .p1 = (x0 + widthf , y0 + heightf )
2109
2114
2110
2115
def get_constrained_layout (self ):
2116
+ """
2117
+ Return whether constrained layout is being used.
2118
+
2119
+ See :doc:`/tutorials/intermediate/constrainedlayout_guide`.
2120
+ """
2111
2121
return self ._parent .get_constrained_layout ()
2112
2122
2113
2123
def get_constrained_layout_pads (self , relative = False ):
2124
+ """
2125
+ Get padding for ``constrained_layout``.
2126
+
2127
+ Returns a list of ``w_pad, h_pad`` in inches and
2128
+ ``wspace`` and ``hspace`` as fractions of the subplot.
2129
+
2130
+ See :doc:`/tutorials/intermediate/constrainedlayout_guide`.
2131
+
2132
+ Parameters
2133
+ ----------
2134
+ relative : bool
2135
+ If `True`, then convert from inches to figure relative.
2136
+ """
2114
2137
return self ._parent .get_constrained_layout_pads (relative = relative )
2115
2138
2116
2139
def init_layoutgrid (self ):
@@ -2132,6 +2155,12 @@ def get_axes(self):
2132
2155
"""
2133
2156
Return a list of axes in the SubFigure. You can access and modify the
2134
2157
axes in the Figure through this list.
2158
+
2159
+ Do not modify the list itself. Instead, use `~.SubFigure.add_axes`,
2160
+ `~.SubFigure.add_subplot` or `~.SubFigure.delaxes` to add or remove an
2161
+ axes.
2162
+
2163
+ Note: This is equivalent to the property `~.Figure.axes`.
2135
2164
"""
2136
2165
return self ._localaxes .as_list ()
2137
2166
@@ -2285,7 +2314,6 @@ def __init__(self,
2285
2314
self .patch .set_antialiased (False )
2286
2315
2287
2316
FigureCanvasBase (self ) # Set self.canvas.
2288
- self ._suptitle = None
2289
2317
2290
2318
if subplotpars is None :
2291
2319
subplotpars = SubplotParams ()
@@ -2303,7 +2331,6 @@ def __init__(self,
2303
2331
self ._cachedRenderer = None
2304
2332
2305
2333
self .set_constrained_layout (constrained_layout )
2306
- self .subfigs = []
2307
2334
2308
2335
# groupers to keep track of x and y labels we want to align.
2309
2336
# see self.align_xlabels and self.align_ylabels and
0 commit comments