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

Skip to content

Commit d010c03

Browse files
committed
Improve docs of _get_packed_offsets, _get_aligned_offsets.
1 parent da66560 commit d010c03

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 24 additions & 19 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+
Horizontally pack boxes specified by their ``(width, xdescent)`` pair.
5851
59-
For simplicity of the description, the terminology used here assumes a
60-
horizontal layout, but the function works equally for a vertical layout.
52+
(For simplicity of the description, the terminology used here assumes a
53+
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,30 @@ 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+
Vertically 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, but the function works equally for a vertical layout.)
144139
145140
Parameters
146141
----------
147142
hd_list
148143
List of (height, xdescent) of boxes to be aligned.
149144
height : float or None
150-
Intended total length. If None, the maximum of the heights in *hd_list*
145+
Intended total height. If None, the maximum of the heights in *hd_list*
151146
is used.
152147
align : {'baseline', 'left', 'top', 'right', 'bottom', 'center'}
153-
Align mode.
148+
The alignment anchor of the boxes.
149+
150+
Returns
151+
-------
152+
height
153+
The total height of the packing (if a value was originally passed in,
154+
it is returned without checking that it is actually large enough).
155+
descent
156+
The descent of the packing.
157+
offsets
158+
The bottom offsets of the boxes.
154159
"""
155160

156161
if height is None:

0 commit comments

Comments
 (0)