Skip to content

Clarify docs of Rectangle #17024

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
Apr 7, 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
35 changes: 22 additions & 13 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,21 @@ def draw(self, renderer):

class Rectangle(Patch):
"""
A rectangle with lower left at *xy* = (*x*, *y*) with
specified *width*, *height* and rotation *angle*.
A rectangle defined via an anchor point *xy* and its *width* and *height*.

The rectangle extends from ``xy[0]`` to ``xy[0] + width`` in x-direction
and from ``xy[1]`` to ``xy[1] + height`` in y-direction. ::

: +------------------+
: | |
: height |
: | |
: (xy)---- width -----+

One may picture *xy* as the bottom left corner, but which corner *xy* is
actually depends on the the direction of the axis and the sign of *width*
and *height*; e.g. *xy* would be the bottom right corner if the x-axis
was inverted or if *width* was negative.
"""

def __str__(self):
Expand All @@ -720,22 +733,18 @@ def __init__(self, xy, width, height, angle=0.0, **kwargs):
Parameters
----------
xy : (float, float)
The rectangle extends from xy[0] to xy[0] + width in
x-direction and from xy[1] to xy[1] + height in y-direction.
The anchor point.
width : float
Rectangle width
Rectangle width.
height : float
Rectangle height
Rectangle height.
angle : float, default: 0
Rotation in degrees anti-clockwise about *xy*.
fill : bool, default: True
Whether to fill the rectangle.

Notes
-----
Valid keyword arguments are:

%(Patch)s
Other Parameters
----------------
**kwargs : `.Patch` properties
%(Patch)s
"""

Patch.__init__(self, **kwargs)
Expand Down