Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f542c0b

Browse files
committed
FIX: more comments
1 parent b29581a commit f542c0b

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

lib/matplotlib/figure.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,8 +1472,11 @@ def subfigures(self, nrows=1, ncols=1, squeeze=True,
14721472
width_ratios=None, height_ratios=None,
14731473
**kwargs):
14741474
"""
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`.
14771480
14781481
Parameters
14791482
----------
@@ -2056,6 +2059,7 @@ def __init__(self, parent, subplotspec, *,
20562059
facecolor=facecolor, edgecolor=edgecolor, linewidth=linewidth,
20572060
# Don't let the figure patch influence bbox calculation.
20582061
in_layout=False, transform=self.transSubfigure)
2062+
self._set_artist_props(self.patch)
20592063
self.patch.set_antialiased(False)
20602064

20612065
if parent._layoutgrid is not None:
@@ -2094,12 +2098,13 @@ def _redo_transform_rel_fig(self, bbox=None):
20942098
heightf = np.sum(hr[self._subplotspec.rowspan]) / np.sum(hr)
20952099

20962100
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)
20992103

21002104
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.stop - 1]) /
2107+
np.sum(hr))
21032108

21042109
if self.bbox_relative is None:
21052110
self.bbox_relative = Bbox.from_bounds(x0, y0, widthf, heightf)
@@ -2108,9 +2113,27 @@ def _redo_transform_rel_fig(self, bbox=None):
21082113
self.bbox_relative.p1 = (x0 + widthf, y0 + heightf)
21092114

21102115
def get_constrained_layout(self):
2116+
"""
2117+
Return whether constrained layout is being used.
2118+
2119+
See :doc:`/tutorials/intermediate/constrainedlayout_guide`.
2120+
"""
21112121
return self._parent.get_constrained_layout()
21122122

21132123
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+
"""
21142137
return self._parent.get_constrained_layout_pads(relative=relative)
21152138

21162139
def init_layoutgrid(self):
@@ -2132,6 +2155,12 @@ def get_axes(self):
21322155
"""
21332156
Return a list of axes in the SubFigure. You can access and modify the
21342157
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`.
21352164
"""
21362165
return self._localaxes.as_list()
21372166

@@ -2285,7 +2314,6 @@ def __init__(self,
22852314
self.patch.set_antialiased(False)
22862315

22872316
FigureCanvasBase(self) # Set self.canvas.
2288-
self._suptitle = None
22892317

22902318
if subplotpars is None:
22912319
subplotpars = SubplotParams()
@@ -2303,7 +2331,6 @@ def __init__(self,
23032331
self._cachedRenderer = None
23042332

23052333
self.set_constrained_layout(constrained_layout)
2306-
self.subfigs = []
23072334

23082335
# groupers to keep track of x and y labels we want to align.
23092336
# see self.align_xlabels and self.align_ylabels and

0 commit comments

Comments
 (0)