Skip to content

fix: resolve FigureCanvasTkAgg clipping on Windows HiDPI#31133

Open
intelliking wants to merge 4 commits intomatplotlib:mainfrom
intelliking:fix/issue-31126
Open

fix: resolve FigureCanvasTkAgg clipping on Windows HiDPI#31133
intelliking wants to merge 4 commits intomatplotlib:mainfrom
intelliking:fix/issue-31126

Conversation

@intelliking
Copy link

PR summary

Closes #31126

Why is this change necessary?

  • On HiDPI displays, FigureCanvasTkAgg embedded in layout-managed containers renders plots larger than the visible area, clipping axis labels and legends.

What problem does it solve?

  • When DPI changes, the canvas is configured to a larger size but layout managers constrain it, preventing the <Configure> event from firing and leaving figure.size_inches miscalculated, causing the render buffer to exceed the visible canvas size.

What is the reasoning for this implementation?

  • After configuring canvas size, explicitly check if the actual displayed size differs from the configured size and call resize() to recalculate figure.size_inches with the correct DPI, ensuring render size matches visible size.

PR checklist

@github-actions
Copy link

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@tacaswell
Copy link
Member

I think I understand how this works, but it feels like there should be a better way in tk for widgets to be notified that their size is changed. We should be using that mechanism (possibly re-working how we currently do it) instead#.

@intelliking
Copy link
Author

I think I understand how this works, but it feels like there should be a better way in tk for widgets to be notified that their size is changed. We should be using that mechanism (possibly re-working how we currently do it) instead#.

Thanks @tacaswell , I see what you mean. I’ll try to find a better Tk-native way for widgets to react to size changes and rework the current approach based on that.

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]: FigureCanvasTkAgg renders clipped/oversized when embedded in layout-managed container on Windows HiDPI

2 participants