[Matplotlib-users] Line mode of RectangleSelector broken or no longer intuitive

Lars Bittrich lars.bittrich at gmail.com
Wed Apr 12 10:47:45 EDT 2017

Dear all,

I recently upgraded to matplotlib 2.0 and found a regression with
RectangleSelector with drawtype='line'. A line is no longer draw between
start point and end point, but from lower left to upper right of an
imaginary rectangle. So you can no longer select a downward slope.

This behavior may have been around for some time and most users will just
use RectangleSelector with a rectangle and not a line. There has been a
mail on this list regarding the return values only:


But also the interactive drawing is affected. I looked into the
corresponding code and found quite a lot of sorting of x and y values
separately. To restore the old behavior one would need many changes to the
worse from my point of view.

Please note, that the docstring for RectangleSelector still advertises the
‘line’-mode even if the ‘box’ mode is default now. This example clearly
illustrates the problem.

However, I suggest and request for people like me, who want so select a
line in a plot to add a LineSelector instead of changing RectangleSelector
to the old behavior and maybe break some code for the ‘box’-mode again.
This would be much more intuitive for new users.

I added such a LineSelector and attached a patch for widgets.py based on a
much reduced copy of RectangleSelector. There still is some code duplicated
in the _release method, which could be resolved with a common base class,
but would require more changes. Additionally, there are some changes in the
docstring of RectangleSelector to use the box-mode and change the print
statement to clearly state that start point and end point are no longer
returned. In future one could add a deprecation warning and point users to
LineSelector if the RectangleSelector is used in line-mode.

Best regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170412/2c0fb814/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: widgets.patch
Type: application/octet-stream
Size: 8015 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170412/2c0fb814/attachment.obj>

More information about the Matplotlib-users mailing list