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

Skip to content

Commit af6e1b4

Browse files
committed
Fix handling of center handle
1 parent e802991 commit af6e1b4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def onselect(epress, erelease):
119119
pass
120120

121121
tool = widgets.EllipseSelector(ax, onselect=onselect,
122-
maxdist=10)
122+
maxdist=10, interactive=True)
123123
tool.extents = (100, 150, 100, 150)
124124

125125
# drag the rectangle
@@ -193,7 +193,7 @@ def onselect(epress, erelease):
193193
do_event(tool, 'press', xdata=132, ydata=132)
194194
do_event(tool, 'onmove', xdata=120, ydata=120)
195195
do_event(tool, 'release', xdata=120, ydata=120)
196-
assert tool.extents == (108, 138, 108, 138)
196+
assert tool.extents == (108, 138, 108, 138), tool.extents
197197

198198
# create a new rectangle
199199
do_event(tool, 'press', xdata=10, ydata=10)

lib/matplotlib/widgets.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,8 @@ def __init__(self, ax, onselect, drawtype='patch',
17781778
if not self.interactive:
17791779
self.artists = [self.to_draw]
17801780

1781+
self._extents_on_press = None
1782+
17811783
def _press(self, event):
17821784
"""on button press event"""
17831785
# make the drawed box/line visible get the click-coordinates,
@@ -1853,7 +1855,8 @@ def _onmove(self, event):
18531855
y2 = event.ydata
18541856

18551857
# move existing shape
1856-
elif 'move' in self.state:
1858+
elif (('move' in self.state or self.active_handle == 'C')
1859+
and self._extents_on_press is not None):
18571860
x1, x2, y1, y2 = self._extents_on_press
18581861
dx = event.xdata - self.eventpress.xdata
18591862
dy = event.ydata - self.eventpress.ydata

0 commit comments

Comments
 (0)