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

Skip to content

Commit c825652

Browse files
committed
Fix stay_span to reset onclick in SpanSelector.
1 parent a8ae66e commit c825652

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

lib/matplotlib/widgets.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,8 @@ def _press(self, event):
18201820
self.pressv = xdata
18211821
else:
18221822
self.pressv = ydata
1823+
1824+
self._set_span_xy(event)
18231825
return False
18241826

18251827
def _release(self, event):
@@ -1858,6 +1860,26 @@ def _onmove(self, event):
18581860
"""on motion notify event"""
18591861
if self.pressv is None:
18601862
return
1863+
1864+
self._set_span_xy(event)
1865+
1866+
if self.onmove_callback is not None:
1867+
vmin = self.pressv
1868+
xdata, ydata = self._get_data(event)
1869+
if self.direction == 'horizontal':
1870+
vmax = xdata or self.prev[0]
1871+
else:
1872+
vmax = ydata or self.prev[1]
1873+
1874+
if vmin > vmax:
1875+
vmin, vmax = vmax, vmin
1876+
self.onmove_callback(vmin, vmax)
1877+
1878+
self.update()
1879+
return False
1880+
1881+
def _set_span_xy(self, event):
1882+
"""Setting the span coordinates"""
18611883
x, y = self._get_data(event)
18621884
if x is None:
18631885
return
@@ -1878,21 +1900,6 @@ def _onmove(self, event):
18781900
self.rect.set_y(minv)
18791901
self.rect.set_height(maxv - minv)
18801902

1881-
if self.onmove_callback is not None:
1882-
vmin = self.pressv
1883-
xdata, ydata = self._get_data(event)
1884-
if self.direction == 'horizontal':
1885-
vmax = xdata or self.prev[0]
1886-
else:
1887-
vmax = ydata or self.prev[1]
1888-
1889-
if vmin > vmax:
1890-
vmin, vmax = vmax, vmin
1891-
self.onmove_callback(vmin, vmax)
1892-
1893-
self.update()
1894-
return False
1895-
18961903

18971904
class ToolHandles(object):
18981905
"""Control handles for canvas tools.

0 commit comments

Comments
 (0)