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

Skip to content

Commit d786d6a

Browse files
authored
Merge pull request #19013 from anntzer/gpao
Improve docs of _get_packed_offsets, _get_aligned_offsets.
2 parents bfc1279 + 5f72e0c commit d786d6a

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,18 @@ def bbox_artist(*args, **kwargs):
4444
if DEBUG:
4545
mbbox_artist(*args, **kwargs)
4646

47-
# _get_packed_offsets() and _get_aligned_offsets() are coded assuming
48-
# that we are packing boxes horizontally. But same function will be
49-
# used with vertical packing.
50-
5147

5248
def _get_packed_offsets(wd_list, total, sep, mode="fixed"):
53-
"""
54-
Given a list of (width, xdescent) of each boxes, calculate the
55-
total width and the x-offset positions of each items according to
56-
*mode*. xdescent is analogous to the usual descent, but along the
57-
x-direction. xdescent values are currently ignored.
49+
r"""
50+
Pack boxes specified by their ``(width, xdescent)`` pair.
5851
5952
For simplicity of the description, the terminology used here assumes a
6053
horizontal layout, but the function works equally for a vertical layout.
6154
62-
There are three packing modes:
55+
*xdescent* is analogous to the usual descent, but along the x-direction; it
56+
is currently ignored.
57+
58+
There are three packing *mode*\s:
6359
6460
- 'fixed': The elements are packed tight to the left with a spacing of
6561
*sep* in between. If *total* is *None* the returned total will be the
@@ -136,21 +132,31 @@ def _get_packed_offsets(wd_list, total, sep, mode="fixed"):
136132

137133
def _get_aligned_offsets(hd_list, height, align="baseline"):
138134
"""
139-
Given a list of (height, descent) of each boxes, align the boxes
140-
with *align* and calculate the y-offsets of each boxes.
141-
total width and the offset positions of each items according to
142-
*mode*. xdescent is analogous to the usual descent, but along the
143-
x-direction. xdescent values are currently ignored.
135+
Align boxes each specified by their ``(height, descent)`` pair.
136+
137+
For simplicity of the description, the terminology used here assumes a
138+
horizontal layout (i.e., vertical alignment), but the function works
139+
equally for a vertical layout.
144140
145141
Parameters
146142
----------
147143
hd_list
148144
List of (height, xdescent) of boxes to be aligned.
149145
height : float or None
150-
Intended total length. If None, the maximum of the heights in *hd_list*
146+
Intended total height. If None, the maximum of the heights in *hd_list*
151147
is used.
152148
align : {'baseline', 'left', 'top', 'right', 'bottom', 'center'}
153-
Align mode.
149+
The alignment anchor of the boxes.
150+
151+
Returns
152+
-------
153+
height
154+
The total height of the packing (if a value was originally passed in,
155+
it is returned without checking that it is actually large enough).
156+
descent
157+
The descent of the packing.
158+
offsets
159+
The bottom offsets of the boxes.
154160
"""
155161

156162
if height is None:

0 commit comments

Comments
 (0)