8000 Consistent corner variables names in widgets.py by dstansby · Pull Request #19853 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Consistent corner variables names in widgets.py #19853

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 2, 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
52 changes: 26 additions & 26 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2359,16 +2359,16 @@ def _release(self, event):
self.to_draw.set_visible(False)

# update the eventpress and eventrelease with the resulting extents
x1, x2, y1, y2 = self.extents
self.eventpress.xdata = x1
self.eventpress.ydata = y1
x0, x1, y0, y1 = self.extents
self.eventpress.xdata = x0
self.eventpress.ydata = y0
xy0 = self.ax.transData.transform([x0, y0])
self.eventpress.x, self.eventpress.y = xy0

self.eventrelease.xdata = x1
self.eventrelease.ydata = y1
xy1 = self.ax.transData.transform([x1, y1])
self.eventpress.x, self.eventpress.y = xy1

self.eventrelease.xdata = x2
self.eventrelease.ydata = y2
xy2 = self.ax.transData.transform([x2, y2])
self.eventrelease.x, self.eventrelease.y = xy2
self.eventrelease.x, self.eventrelease.y = xy1

# calculate dimensions of box or line
if self.spancoords == 'data':
Expand Down Expand Up @@ -2400,22 +2400,22 @@ def _onmove(self, event):
"""Motion notify event handler."""
# resize an existing shape
if self.active_handle and self.active_handle != 'C':
x1, x2, y1, y2 = self._extents_on_press
x0, x1, y0, y1 = self._extents_on_press
if self.active_handle in ['E', 'W'] + self._corner_order:
x2 = event.xdata
x1 = event.xdata
if self.active_handle in ['N', 'S'] + self._corner_order:
y2 = event.ydata
y1 = event.ydata

# move existing shape
elif (('move' in self.state or self.active_handle == 'C')
and self._extents_on_press is not None):
x1, x2, y1, y2 = self._extents_on_press
x0, x1, y0, y1 = self._extents_on_press
dx = event.xdata - self.eventpress.xdata
dy = event.ydata - self.eventpress.ydata
x0 += dx
x1 += dx
x2 += dx
y0 += dy
y1 += dy
y2 += dy

# new shape
else:
Expand Down Expand Up @@ -2446,10 +2446,10 @@ def _onmove(self, event):
center[0] += dx
center[1] += dy

x1, x2, y1, y2 = (center[0] - dx, center[0] + dx,
x0, x1, y0, y1 = (center[0] - dx, center[0] + dx,
center[1] - dy, center[1] + dy)

self.extents = x1, x2, y1, y2
self.extents = x0, x1, y0, y1

@property
def _rect_bbox(self):
Expand Down Expand Up @@ -2552,13 +2552,13 @@ def _set_active_handle(self, event):
self.active_handle = self._edge_order[e_idx]

# Save coordinates of rectangle at the start of handle movement.
x1, x2, y1, y2 = self.extents
# Switch variables so that only x2 and/or y2 are updated on move.
x0, x1, y0, y1 = self.extents
# Switch variables so that only x1 and/or y1 are updated on move.
if self.active_handle in ['W', 'SW', 'NW']:
x1, x2 = x2, event.xdata
x0, x1 = x1, event.xdata
if self.active_handle in ['N', 'NW', 'NE']:
y1, y2 = y2, event.ydata
self._extents_on_press = x1, x2, y1, y2
y0, y1 = y1, event.ydata
self._extents_on_press = x0, x1, y0, y1

@property
def geometry(self):
Expand Down Expand Up @@ -2616,10 +2616,10 @@ def toggle_selector(event):
_shape_klass = Ellipse

def draw_shape(self, extents):
x1, x2, y1, y2 = extents
xmin, xmax = sorted([x1, x2])
ymin, ymax = sorted([y1, y2])
center = [x1 + (x2 - x1) / 2., y1 + (y2 - y1) / 2.]
x0, x1, y0, y1 = extents
xmin, xmax = sorted([x0, x1])
ymin, ymax = sorted([y0, y1])
center = [x0 + (x1 - x0) / 2., y0 + (y1 - y0) / 2.]
a = (xmax - xmin) / 2.
b = (ymax - ymin) / 2.

Expand Down
0