Skip to content

Widgets: RectangleSelector in Mpl 2.1.0 does not behave as described #9608

Closed as not planned

Description

@alsast

Bug report

In Python 3.6.3 and the related matplotlib (just compiled from sources) the RectangleSelector does no longer behave as in Python 2.7 and as is described. Instead of returning the mouse click coordinates in the event variable eclick and the release coordinates in erelease it returns the lower left corner in eclick and the upper right corner in erelease. This "normalization" reduces the information content and, thus, the usability of the selector. Only using the old version a user can switch to drawmode='line' and use the selector to input a displacement vector.

Activity

  1. tacaswell commented on Oct 29, 2017

    @tacaswell
    Member

    What version of Matplotlib are you testing? I would be very surprised if this changes is tied to the version of python.

  2. alsast commented on Oct 30, 2017

    @alsast
    Author

    Well, the python3 uses matplotlib 2.1.0 and there the RectangleSelector does not behave like described -- the python2 has matplotlib 1.3.1 installed, where the code reflects the description.

  3. added this to the milestone on Oct 30, 2017
  4. added
    API: changesChanges to the public API, typically requiring deprecation.
    and removed on Oct 30, 2017
  5. changed the title [-]Widgets: RectangleSelector in 3.6.3 does not behave as described[/-] [+]Widgets: RectangleSelector in Mpl 2.1.0 does not behave as described[/+] on Oct 30, 2017
  6. tacaswell commented on Oct 30, 2017

    @tacaswell
    Member

    @alsast Sorry we broke this for you.

    I suspect that this was a consequence of #3937 which went in for 1.5. At a minimum we need to fix the docstring to reflect the current behavior and consider flipping it back or making it configurable. I have a memory of another discussion of this, but can not find it quickly.

    I think the normalization of the points made managing the resizing of selection region tractable? attn @blink1073

  7. blink1073 commented on Oct 30, 2017

    @blink1073
    Member

    The normalization was added because you might be dragging one of the handles, or the whole object. It could be improved to preserve the order though so you don't lose information.

    x1, x2, y1, y2 = self.extents
    self.eventpress.xdata = x1
    self.eventpress.ydata = y1
    xy1 = self.ax.transData.transform_point([x1, y1])
    self.eventpress.x, self.eventpress.y = xy1
    self.eventrelease.xdata = x2
    self.eventrelease.ydata = y2
    xy2 = self.ax.transData.transform_point([x2, y2])
    self.eventrelease.x, self.eventrelease.y = xy2

  8. blink1073 commented on Oct 30, 2017

    @blink1073
    Member

    Actually, it isn't just order. What we could do is only normalize if the events aren't both part of the new corner points.

  9. blink1073 commented on Oct 30, 2017

    @blink1073
    Member

    Or we could revert entirely and you use the extents if you need the true corners.

  10. rowlesmr commented on Jul 8, 2021

    @rowlesmr

    Can the RectangleSelector be made configurable to report either extents or the actual mouse press and release coordinates?

    If this is a thing that people think is OK, I'll try and figure out how to write a patch for it.

  11. anntzer commented on Jul 8, 2021

    @anntzer
    Contributor

    I would rather go with

    Or we could revert entirely and you use the extents if you need the true corners.

    rather than adding more configurability...

  12. rowlesmr commented on Jul 8, 2021

    @rowlesmr

    OK. I'll see if I can contribute: Make the behaviour for onselect for RectangleSelector match the docstring (again). If you need extents, then you can call that explicitly.

  13. rowlesmr commented on Jul 10, 2021

    @rowlesmr

    I've submitted a PR for this issue: #20611

  14. tacaswell commented on Aug 12, 2021

    @tacaswell
    Member

    re-reading this again, I noticed

    Only using the old version a user can switch to drawmode='line' and use the selector to input a displacement vector.

    which was a very clever use of RectangleSelector to get a VectorSelector even if we did not understand that we provided it! @alsast Sorry for not understanding you correctly in 2017.

    However, I think that at this point (~4 years later) it is too late to revert the change to RectangleSelector on the risk that we now have users who are relying on the new order. I think the two actions we should take from this issue are

    1. update the documentation of RectangleSelector to make it match what the code does
    2. implement a VectorSelector that is intended from selecting displacement vectors. Now that we have a growing convention around putting handles on the selectors, I think it would make sense to be Line2D with handles on each and and one in the middle.
  15. github-actions commented on Apr 22, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  16. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: changesChanges to the public API, typically requiring deprecation.Documentationstatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Actiontopic: widgets/UI

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions