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

Skip to content

Commit de4933c

Browse files
authored
Merge pull request #17024 from timhoffm/doc-rectangle
Clarify docs of Rectangle
2 parents 3f78c1a + dac810e commit de4933c

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

lib/matplotlib/patches.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,21 @@ def draw(self, renderer):
705705

706706
class Rectangle(Patch):
707707
"""
708-
A rectangle with lower left at *xy* = (*x*, *y*) with
709-
specified *width*, *height* and rotation *angle*.
708+
A rectangle defined via an anchor point *xy* and its *width* and *height*.
709+
710+
The rectangle extends from ``xy[0]`` to ``xy[0] + width`` in x-direction
711+
and from ``xy[1]`` to ``xy[1] + height`` in y-direction. ::
712+
713+
: +------------------+
714+
: | |
715+
: height |
716+
: | |
717+
: (xy)---- width -----+
718+
719+
One may picture *xy* as the bottom left corner, but which corner *xy* is
720+
actually depends on the the direction of the axis and the sign of *width*
721+
and *height*; e.g. *xy* would be the bottom right corner if the x-axis
722+
was inverted or if *width* was negative.
710723
"""
711724

712725
def __str__(self):
@@ -720,22 +733,18 @@ def __init__(self, xy, width, height, angle=0.0, **kwargs):
720733
Parameters
721734
----------
722735
xy : (float, float)
723-
The rectangle extends from xy[0] to xy[0] + width in
724-
x-direction and from xy[1] to xy[1] + height in y-direction.
736+
The anchor point.
725737
width : float
726-
Rectangle width
738+
Rectangle width.
727739
height : float
728-
Rectangle height
740+
Rectangle height.
729741
angle : float, default: 0
730742
Rotation in degrees anti-clockwise about *xy*.
731-
fill : bool, default: True
732-
Whether to fill the rectangle.
733-
734-
Notes
735-
-----
736-
Valid keyword arguments are:
737743
738-
%(Patch)s
744+
Other Parameters
745+
----------------
746+
**kwargs : `.Patch` properties
747+
%(Patch)s
739748
"""
740749

741750
Patch.__init__(self, **kwargs)

0 commit comments

Comments
 (0)