Skip to content
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
25 changes: 8 additions & 17 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2094,30 +2094,21 @@ def _release(self, event):
xy2 = self.ax.transData.transform([x2, y2])
self.eventrelease.x, self.eventrelease.y = xy2

# calculate dimensions of box or line
if self.spancoords == 'data':
xmin, ymin = self.eventpress.xdata, self.eventpress.ydata
xmax, ymax = self.eventrelease.xdata, self.eventrelease.ydata
# calculate dimensions of box or line get values in the right order
spanx = abs(self.eventpress.xdata - self.eventrelease.xdata)
spany = abs(self.eventpress.ydata - self.eventrelease.ydata)
elif self.spancoords == 'pixels':
xmin, ymin = self.eventpress.x, self.eventpress.y
xmax, ymax = self.eventrelease.x, self.eventrelease.y
spanx = abs(self.eventpress.x - self.eventrelease.x)
spany = abs(self.eventpress.y - self.eventrelease.y)
else:
cbook._check_in_list(['data', 'pixels'],
spancoords=self.spancoords)

if xmin > xmax:
xmin, xmax = xmax, xmin
if ymin > ymax:
ymin, ymax = ymax, ymin

spanx = xmax - xmin
spany = ymax - ymin
xproblems = self.minspanx is not None and spanx < self.minspanx
yproblems = self.minspany is not None and spany < self.minspany

# check if drawn distance (if it exists) is not too small in
# either x or y-direction
if self.drawtype != 'none' and (xproblems or yproblems):
if (self.drawtype != 'none'
and (self.minspanx is not None and spanx < self.minspanx
or self.minspany is not None and spany < self.minspany)):
for artist in self.artists:
artist.set_visible(False)
self.update()
Expand Down