Skip to content

ENH: Preserve PolygonSelector cursor position after clear - #32195

Open
lucaznch wants to merge 1 commit into
matplotlib:mainfrom
lucaznch:enh-cursor-after-clear
Open

ENH: Preserve PolygonSelector cursor position after clear#32195
lucaznch wants to merge 1 commit into
matplotlib:mainfrom
lucaznch:enh-cursor-after-clear

Conversation

@lucaznch

Copy link
Copy Markdown
Contributor

PR summary

Closes #28220

When pressing the Escape key to clear a polygonal chain, the pending vertex representing the cursor is reset to (0, 0) and rendered.

This PR enhances that behavior by reseting the pending vertex to the last known cursor position, falling back to the center of the axes if unknown.

Using the last known cursor position provides a more pleasant visualization interactively, and the center of the axes is preferable to (0, 0) since it is guaranteed to be visible.

Visual comparison

Current

current.mp4

Proposed

proposed.mp4

AI Disclosure

The implementation is my own but I asked chatgpt to review it, and it recommended guarding against NaN, which I added.

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • [N/A] Plotting related features are demonstrated in an example
  • New features and API changes have release notes
  • [N/A] Documentation complies with general and docstring guidelines

When pressing the Escape key to clear a polygonal chain, the pending
vertex representing the cursor is reset to (0, 0) and rendered.

This commit enhances that behavior by resetting the pending vertex to the
last known cursor position, falling back to the center of the axes if unknown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH]: matplotlib.widgets.PolygonSelector widget initial cursor position at data rather than (0,0)

1 participant