Skip to content

Clarify coordinates for RectangleSelector properties #21952

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 2 commits into from
Dec 15, 2021
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
21 changes: 13 additions & 8 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3233,7 +3233,10 @@ def _get_rotation_transform(self):

@property
def corners(self):
"""Corners of rectangle from lower left, moving clockwise."""
"""
Corners of rectangle in data coordinates from lower left,
moving clockwise.
"""
x0, y0, width, height = self._rect_bbox
xc = x0, x0 + width, x0 + width, x0
yc = y0, y0, y0 + height, y0 + height
Expand All @@ -3243,7 +3246,10 @@ def corners(self):

@property
def edge_centers(self):
"""Midpoint of rectangle edges from left, moving anti-clockwise."""
"""
Midpoint of rectangle edges in data coordiantes from left,
moving anti-clockwise.
"""
x0, y0, width, height = self._rect_bbox
w = width / 2.
h = height / 2.
Expand All @@ -3255,15 +3261,15 @@ def edge_centers(self):

@property
def center(self):
"""Center of rectangle."""
"""Center of rectangle in data coordinates."""
x0, y0, width, height = self._rect_bbox
return x0 + width / 2., y0 + height / 2.

@property
def extents(self):
"""
Return (xmin, xmax, ymin, ymax) as defined by the bounding box before
rotation.
Return (xmin, xmax, ymin, ymax) in data coordinates as defined by the
bounding box before rotation.
"""
x0, y0, width, height = self._rect_bbox
xmin, xmax = sorted([x0, x0 + width])
Expand Down Expand Up @@ -3360,9 +3366,8 @@ def geometry(self):
"""
Return an array of shape (2, 5) containing the
x (``RectangleSelector.geometry[1, :]``) and
y (``RectangleSelector.geometry[0, :]``) coordinates
of the four corners of the rectangle starting and ending
in the top left corner.
y (``RectangleSelector.geometry[0, :]``) data coordinates of the four
corners of the rectangle starting and ending in the top left corner.
"""
if hasattr(self._selection_artist, 'get_verts'):
xfm = self.ax.transData.inverted()
Expand Down