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

Skip to content

Commit 66eb81f

Browse files
committed
Merge pull request #6642 from blink1073/fix-rectangle-selector
FIX: rectangle selector release bug Close #6623.
1 parent 456abce commit 66eb81f

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

lib/matplotlib/widgets.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,18 @@ def _release(self, event):
18271827
if not self.interactive:
18281828
self.to_draw.set_visible(False)
18291829

1830+
# update the eventpress and eventrelease with the resulting extents
1831+
x1, x2, y1, y2 = self.extents
1832+
self.eventpress.xdata = x1
1833+
self.eventpress.ydata = y1
1834+
xy1 = self.ax.transData.transform_point([x1, y1])
1835+
self.eventpress.x, self.eventpress.y = xy1
1836+
1837+
self.eventrelease.xdata = x2
1838+
self.eventrelease.ydata = y2
1839+
xy2 = self.ax.transData.transform_point([x2, y2])
1840+
self.eventrelease.x, self.eventrelease.y = xy2
1841+
18301842
if self.spancoords == 'data':
18311843
xmin, ymin = self.eventpress.xdata, self.eventpress.ydata
18321844
xmax, ymax = self.eventrelease.xdata, self.eventrelease.ydata
@@ -1848,27 +1860,16 @@ def _release(self, event):
18481860
xproblems = self.minspanx is not None and spanx < self.minspanx
18491861
yproblems = self.minspany is not None and spany < self.minspany
18501862

1851-
if (((self.drawtype == 'box') or (self.drawtype == 'line')) and
1852-
(xproblems or yproblems)):
1853-
# check if drawn distance (if it exists) is not too small in
1854-
# neither x nor y-direction
1855-
self.extents = [0, 0, 0, 0]
1863+
# check if drawn distance (if it exists) is not too small in
1864+
# either x or y-direction
1865+
if self.drawtype != 'none' and (xproblems or yproblems):
1866+
for artist in self.artists:
1867+
artist.set_visible(False)
1868+
self.update()
18561869
return
18571870

1858-
# update the eventpress and eventrelease with the resulting extents
1859-
x1, x2, y1, y2 = self.extents
1860-
self.eventpress.xdata = x1
1861-
self.eventpress.ydata = y1
1862-
xy1 = self.ax.transData.transform_point([x1, y1])
1863-
self.eventpress.x, self.eventpress.y = xy1
1864-
1865-
self.eventrelease.xdata = x2
1866-
self.eventrelease.ydata = y2
1867-
xy2 = self.ax.transData.transform_point([x2, y2])
1868-
self.eventrelease.x, self.eventrelease.y = xy2
1869-
1871+
# call desired function
18701872
self.onselect(self.eventpress, self.eventrelease)
1871-
# call desired function
18721873
self.update()
18731874

18741875
return False

0 commit comments

Comments
 (0)