From 85c384a190fe6c4c59fa9aa6f9977e41d5b093c7 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sat, 11 May 2019 14:56:43 +0200 Subject: [PATCH] Update FancyBboxPatch docs to numpydoc style --- lib/matplotlib/patches.py | 93 +++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 148aaa3f51d7..e2da8a5ece2d 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -2437,14 +2437,12 @@ def transmute(self, x0, y0, width, height, mutation_size): class FancyBboxPatch(Patch): """ - A fancy box around a rectangle with lower left at *xy*=(*x*, - *y*) with specified width and height. - - :class:`FancyBboxPatch` class is similar to :class:`Rectangle` - class, but it draws a fancy box around the rectangle. The - transformation of the rectangle box to the fancy box is delegated - to the :class:`BoxTransmuterBase` and its derived classes. + A fancy box around a rectangle with lower left at *xy* = (*x*, *y*) + with specified width and height. + `.FancyBboxPatch` is similar to `.Rectangle`, but it draws a fancy box + around the rectangle. The transformation of the rectangle box to the + fancy box is delegated to the `.BoxTransmuterBase` and its derived classes. """ _edge_default = True @@ -2461,25 +2459,42 @@ def __init__(self, xy, width, height, mutation_aspect=None, **kwargs): """ - *xy* = lower left corner + Parameters + ---------- + xy : float, float + The lower left corner of the box. + + width : float + The width of the box. - *width*, *height* + height : float + The height of the box. - *boxstyle* determines what kind of fancy box will be drawn. It - can be a string of the style name with a comma separated - attribute, or an instance of :class:`BoxStyle`. Following box - styles are available. + boxstyle : str or `matplotlib.patches.BoxStyle` + The style of the fancy box. This can either be a `.BoxStyle` + instance or a string of the style name and optionally comma + seprarated attributes (e.g. "Round, pad=0.2"). This string is + passed to `.BoxStyle` to construct a `.BoxStyle` object. See + there for a full documentation. - %(AvailableBoxstyles)s + The following box styles are available: - *mutation_scale* : a value with which attributes of boxstyle - (e.g., pad) will be scaled. default=1. + %(AvailableBoxstyles)s - *mutation_aspect* : The height of the rectangle will be - squeezed by this value before the mutation and the mutated - box will be stretched by the inverse of it. default=None. + mutation_scale : float, optional, default: 1 + Scaling factor applied to the attributes of the box style + (e.g. pad or rounding_size). + + mutation_aspect : float, optional + The height of the rectangle will be squeezed by this value before + the mutation and the mutated box will be stretched by the inverse + of it. For example, this allows different horizontal and vertical + padding. + + Other Parameters + ---------------- + **kwargs : `.Patch` properties - Valid kwargs are: %(Patch)s """ @@ -2546,9 +2561,7 @@ def set_mutation_scale(self, scale): self.stale = True def get_mutation_scale(self): - """ - Return the mutation scale. - """ + """Return the mutation scale.""" return self._mutation_scale def set_mutation_aspect(self, aspect): @@ -2563,20 +2576,15 @@ def set_mutation_aspect(self, aspect): self.stale = True def get_mutation_aspect(self): - """ - Return the aspect ratio of the bbox mutation. - """ + """Return the aspect ratio of the bbox mutation.""" return self._mutation_aspect def get_boxstyle(self): - "Return the boxstyle object" + """Return the boxstyle object.""" return self._bbox_transmuter def get_path(self): - """ - Return the mutated path of the rectangle - """ - + """Return the mutated path of the rectangle.""" _path = self.get_boxstyle()(self._x, self._y, self._width, self._height, self.get_mutation_scale(), @@ -2586,19 +2594,19 @@ def get_path(self): # Following methods are borrowed from the Rectangle class. def get_x(self): - "Return the left coord of the rectangle" + """Return the left coord of the rectangle.""" return self._x def get_y(self): - "Return the bottom coord of the rectangle" + """Return the bottom coord of the rectangle.""" return self._y def get_width(self): - "Return the width of the rectangle" + """Return the width of the rectangle.""" return self._width def get_height(self): - "Return the height of the rectangle" + """Return the height of the rectangle.""" return self._height def set_x(self, x): @@ -2647,9 +2655,19 @@ def set_height(self, h): def set_bounds(self, *args): """ - Set the bounds of the rectangle: l,b,w,h + Set the bounds of the rectangle. - ACCEPTS: (left, bottom, width, height) + Call signatures:: + + set_bounds(left, bottom, width, height) + set_bounds((left, bottom, width, height)) + + Parameters + ---------- + left, bottom : float + The coordinates of the bottom left corner of the rectangle. + width, height : float + The width/height of the rectangle. """ if len(args) == 1: l, b, w, h = args[0] @@ -2662,6 +2680,7 @@ def set_bounds(self, *args): self.stale = True def get_bbox(self): + """Return the `.Bbox` of the rectangle.""" return transforms.Bbox.from_bounds(self._x, self._y, self._width, self._height)