Skip to content

Fix occasional misalignment in reported mouse position#32038

Draft
ayshih wants to merge 1 commit into
matplotlib:mainfrom
ayshih:mouseover_misalignment
Draft

Fix occasional misalignment in reported mouse position#32038
ayshih wants to merge 1 commit into
matplotlib:mainfrom
ayshih:mouseover_misalignment

Conversation

@ayshih

@ayshih ayshih commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

PR summary

Due to floating-point precision, a figure may self-report a height that is not exactly an integer, and the consequence is a bug for GUI backends where the reported Y position of the mouse may be off by a pixel. This PR fixes the bug in various backends by immediately rounding the figure height rather than letting it be truncated later.

Fixes #27570

AI Disclosure

No AI was used

PR checklist

@timhoffm

Copy link
Copy Markdown
Member

I’m wondering whether we should make an explicit concept out of this. While figure size can be any float, the canvas - at least for raster backends - must be integer. So it seems we should rather take the size from the canvas? Possibly https://matplotlib.org/stable/api/backend_bases_api.html#matplotlib.backend_bases.FigureCanvasBase.get_width_height

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.

[Bug]: QuadMesh.get_cursor_data() returns incorrect value

2 participants