Skip to content

Commit 2e6e491

Browse files
authored
Merge pull request #19012 from anntzer/packerbase
Common `__init__` for VPacker and HPacker.
2 parents b779509 + 9764734 commit 2e6e491

File tree

1 file changed

+10
-86
lines changed

1 file changed

+10
-86
lines changed

lib/matplotlib/offsetbox.py

+10-86
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,8 @@ def draw(self, renderer):
367367

368368
class PackerBase(OffsetBox):
369369
def __init__(self, pad=None, sep=None, width=None, height=None,
370-
align=None, mode=None,
371-
children=None):
372-
r"""
370+
align="baseline", mode="fixed", children=None):
371+
"""
373372
Parameters
374373
----------
375374
pad : float, optional
@@ -382,13 +381,14 @@ def __init__(self, pad=None, sep=None, width=None, height=None,
382381
Width and height of the container box in pixels, calculated if
383382
*None*.
384383
385-
align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}
384+
align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}, \
385+
default: 'baseline'
386386
Alignment of boxes.
387387
388-
mode : {'fixed', 'expand', 'equal'}
388+
mode : {'fixed', 'expand', 'equal'}, default: 'fixed'
389389
The packing mode.
390390
391-
- 'fixed' packs the given `.Artist`\s tight with *sep* spacing.
391+
- 'fixed' packs the given `.Artist`\\s tight with *sep* spacing.
392392
- 'expand' uses the maximal available space to distribute the
393393
artists with equal spacing in between.
394394
- 'equal': Each artist an equal fraction of the available space
@@ -403,59 +403,20 @@ def __init__(self, pad=None, sep=None, width=None, height=None,
403403
dpi, while *width* and *height* are in in pixels.
404404
"""
405405
super().__init__()
406-
407406
self.height = height
408407
self.width = width
409408
self.sep = sep
410409
self.pad = pad
411410
self.mode = mode
412411
self.align = align
413-
414412
self._children = children
415413

416414

417415
class VPacker(PackerBase):
418416
"""
419-
The VPacker has its children packed vertically. It automatically
420-
adjusts the relative positions of children at drawing time.
417+
VPacker packs its children vertically, automatically adjusting their
418+
relative positions at draw time.
421419
"""
422-
def __init__(self, pad=None, sep=None, width=None, height=None,
423-
align="baseline", mode="fixed",
424-
children=None):
425-
r"""
426-
Parameters
427-
----------
428-
pad : float, optional
429-
The boundary padding in points.
430-
431-
sep : float, optional
432-
The spacing between items in points.
433-
434-
width, height : float, optional
435-
Width and height of the container box in pixels, calculated if
436-
*None*.
437-
438-
align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}
439-
Alignment of boxes.
440-
441-
mode : {'fixed', 'expand', 'equal'}
442-
The packing mode.
443-
444-
- 'fixed' packs the given `.Artist`\s tight with *sep* spacing.
445-
- 'expand' uses the maximal available space to distribute the
446-
artists with equal spacing in between.
447-
- 'equal': Each artist an equal fraction of the available space
448-
and is left-aligned (or top-aligned) therein.
449-
450-
children : list of `.Artist`
451-
The artists to pack.
452-
453-
Notes
454-
-----
455-
*pad* and *sep* are in points and will be scaled with the renderer
456-
dpi, while *width* and *height* are in in pixels.
457-
"""
458-
super().__init__(pad, sep, width, height, align, mode, children)
459420

460421
def get_extent_offsets(self, renderer):
461422
# docstring inherited
@@ -494,46 +455,9 @@ def get_extent_offsets(self, renderer):
494455

495456
class HPacker(PackerBase):
496457
"""
497-
The HPacker has its children packed horizontally. It automatically
498-
adjusts the relative positions of children at draw time.
458+
HPacker packs its children horizontally, automatically adjusting their
459+
relative positions at draw time.
499460
"""
500-
def __init__(self, pad=None, sep=None, width=None, height=None,
501-
align="baseline", mode="fixed",
502-
children=None):
503-
r"""
504-
Parameters
505-
----------
506-
pad : float, optional
507-
The boundary padding in points.
508-
509-
sep : float, optional
510-
The spacing between items in points.
511-
512-
width, height : float, optional
513-
Width and height of the container box in pixels, calculated if
514-
*None*.
515-
516-
align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}
517-
Alignment of boxes.
518-
519-
mode : {'fixed', 'expand', 'equal'}
520-
The packing mode.
521-
522-
- 'fixed' packs the given `.Artist`\s tight with *sep* spacing.
523-
- 'expand' uses the maximal available space to distribute the
524-
artists with equal spacing in between.
525-
- 'equal': Each artist an equal fraction of the available space
526-
and is left-aligned (or top-aligned) therein.
527-
528-
children : list of `.Artist`
529-
The artists to pack.
530-
531-
Notes
532-
-----
533-
*pad* and *sep* are in points and will be scaled with the renderer
534-
dpi, while *width* and *height* are in in pixels.
535-
"""
536-
super().__init__(pad, sep, width, height, align, mode, children)
537461

538462
def get_extent_offsets(self, renderer):
539463
# docstring inherited

0 commit comments

Comments
 (0)