-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH]: matplotlib.widgets.PolygonSelector widget initial cursor position at data rather than (0,0) #28220
Labels
Comments
👍 Do you want to make a pull request? |
Hi, can I make a PR? |
@Kaustbh please do. |
@rtrwalker can you please tell me how to reproduce the problem, I am not able to reproduce it. |
@Kaustbh copy the example code from Select indices from a collection using polygon selector . Add 500 (or some large number) to grid_x and grid_y .
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
I'm trying this demo of matplotlib.widgets.PolygonSelector widget: Select indices from a collection using polygon selector. The demo as is, is fine because the data is close to (0,0). However, if the data is not near the origin (e.g. add 500 to grid_x and grid_y in the demo) then the PolygonSelector cursor starts at (0,0) when the figure appears and the data is far off and appears small so I have to always zoom in before selecting points. It would be nice if the initial cursor position was relevant to the data.
Proposed solution
In the PolygonSelector widget init method replace:
self._xs, self._ys = [0], [0]
with
self._xs, self._ys = [sum(ax.get_xlim()) / 2], [sum(ax.get_ylim()) / 2
Then the cursor will be in the middle of the axes object that is past to the PolygonSelector initiator.
The text was updated successfully, but these errors were encountered: