Skip to content

Common __init__ for VPacker and HPacker. #19012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 10 additions & 86 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,8 @@ def draw(self, renderer):

class PackerBase(OffsetBox):
def __init__(self, pad=None, sep=None, width=None, height=None,
align=None, mode=None,
children=None):
r"""
align="baseline", mode="fixed", children=None):
"""
Parameters
----------
pad : float, optional
Expand All @@ -382,13 +381,14 @@ def __init__(self, pad=None, sep=None, width=None, height=None,
Width and height of the container box in pixels, calculated if
*None*.

align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}
align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}, \
default: 'baseline'
Alignment of boxes.

mode : {'fixed', 'expand', 'equal'}
mode : {'fixed', 'expand', 'equal'}, default: 'fixed'
The packing mode.

- 'fixed' packs the given `.Artist`\s tight with *sep* spacing.
- 'fixed' packs the given `.Artist`\\s tight with *sep* spacing.
- 'expand' uses the maximal available space to distribute the
artists with equal spacing in between.
- 'equal': Each artist an equal fraction of the available space
Expand All @@ -403,59 +403,20 @@ def __init__(self, pad=None, sep=None, width=None, height=None,
dpi, while *width* and *height* are in in pixels.
"""
super().__init__()

self.height = height
self.width = width
self.sep = sep
self.pad = pad
self.mode = mode
self.align = align

self._children = children


class VPacker(PackerBase):
"""
The VPacker has its children packed vertically. It automatically
adjusts the relative positions of children at drawing time.
VPacker packs its children vertically, automatically adjusting their
relative positions at draw time.
"""
def __init__(self, pad=None, sep=None, width=None, height=None,
align="baseline", mode="fixed",
children=None):
r"""
Parameters
----------
pad : float, optional
The boundary padding in points.

sep : float, optional
The spacing between items in points.

width, height : float, optional
Width and height of the container box in pixels, calculated if
*None*.

align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}
Alignment of boxes.

mode : {'fixed', 'expand', 'equal'}
The packing mode.

- 'fixed' packs the given `.Artist`\s tight with *sep* spacing.
- 'expand' uses the maximal available space to distribute the
artists with equal spacing in between.
- 'equal': Each artist an equal fraction of the available space
and is left-aligned (or top-aligned) therein.

children : list of `.Artist`
The artists to pack.

Notes
-----
*pad* and *sep* are in points and will be scaled with the renderer
dpi, while *width* and *height* are in in pixels.
"""
super().__init__(pad, sep, width, height, align, mode, children)

def get_extent_offsets(self, renderer):
# docstring inherited
Expand Down Expand Up @@ -494,46 +455,9 @@ def get_extent_offsets(self, renderer):

class HPacker(PackerBase):
"""
The HPacker has its children packed horizontally. It automatically
adjusts the relative positions of children at draw time.
HPacker packs its children horizontally, automatically adjusting their
relative positions at draw time.
"""
def __init__(self, pad=None, sep=None, width=None, height=None,
align="baseline", mode="fixed",
children=None):
r"""
Parameters
----------
pad : float, optional
The boundary padding in points.

sep : float, optional
The spacing between items in points.

width, height : float, optional
Width and height of the container box in pixels, calculated if
*None*.

align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}
Alignment of boxes.

mode : {'fixed', 'expand', 'equal'}
The packing mode.

- 'fixed' packs the given `.Artist`\s tight with *sep* spacing.
- 'expand' uses the maximal available space to distribute the
artists with equal spacing in between.
- 'equal': Each artist an equal fraction of the available space
and is left-aligned (or top-aligned) therein.

children : list of `.Artist`
The artists to pack.

Notes
-----
*pad* and *sep* are in points and will be scaled with the renderer
dpi, while *width* and *height* are in in pixels.
"""
super().__init__(pad, sep, width, height, align, mode, children)

def get_extent_offsets(self, renderer):
# docstring inherited
Expand Down