Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
If in a RectangleSelector the mouse does not move between button press and button release, wrong values for start and end coordinates are returned. It seems to me that those coordinates correspond to the last callback where the mouse had been moved between press and release.
The following example code in theMatplotlib documentation illustrates the consequences:
from pylab import *def onselect(eclick, erelease): 'eclick and erelease are matplotlib events at press and release' print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata)) print(' endposition : (%f, %f)' % (erelease.xdata, erelease.ydata)) print(' used button : ', eclick.button)def toggle_selector(event): print(' Key pressed.') if event.key in ['Q', 'q'] and toggle_selector.RS.active: print(' RectangleSelector deactivated.') toggle_selector.RS.set_active(False) if event.key in ['A', 'a'] and not toggle_selector.RS.active: print(' RectangleSelector activated.') toggle_selector.RS.set_active(True)x = arange(100)/(99.0)y = sin(x)fig = figureax = subplot(111)ax.plot(x,y)toggle_selector.RS = RectangleSelector(ax, onselect, drawtype='line')connect('key_press_event', toggle_selector)show()
**If you start with drawing a line, everything works fine. If you then move the mouse to a different point, click it and release it without moving, the previous line shows up again (and the old coordinates are printed to stdout). If you draw a line from upper left to lower right, the detached line makes weird movements.
The example program works correctly with Matplotlib version 1.4.2.
Matplotlib version
- Operating system: Windows 7 Professional 64bit
- Matplotlib version: 2.1.1
- Matplotlib backend (
print(matplotlib.get_backend())
): qt5agg - Python version: 3.6.3
- Jupyter version (if applicable): -
- Other libraries: -
I installed matplotlib with miniconda from the default channel.