FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Fix unstable tkagg small plot size. by sandyowlet · Pull Request #29989 · matplotlib/matplotlib · GitHub

Repository navigation

fix: Fix unstable tkagg small plot size. - #29989

Merged
QuLogic merged 1 commit into
matplotlib:mainfrom
sandyowlet:bugfix/issue-28330
Oct 31, 2025
Merged

QuLogic merged 1 commit into
matplotlib:mainfrom
sandyowlet:bugfix/issue-28330

Conversation

Copy link
Copy Markdown
Contributor

PR summary

Closes #28330 .


Before: Left After: Right

PR checklist

sandyowlet closed this Apr 30, 2025
sandyowlet deleted the bugfix/issue-28330 branch April 30, 2025 06:13
sandyowlet restored the bugfix/issue-28330 branch April 30, 2025 06:18
sandyowlet reopened this Apr 30, 2025

dstansby commented May 5, 2025

Copy link
Copy Markdown
Member

Thanks for the fix, it looks good to me. Could you add a comment in the code, since I don't think it's super obvious what pack_propagate() is achieving here. Something like # Don't resize the toolbar when mouse coordinates are shown or not shown.

dstansby modified the milestones: v3.10.2, v3.10.3 May 5, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the fix, it looks good to me. Could you add a comment in the code, since I don't think it's super obvious what pack_propagate() is achieving here. Something like # Don't resize the toolbar when mouse coordinates are shown or not shown.

How about this:

         tk.Frame.__init__(self, master=window, borderwidth=2,
                           width=int(canvas.figure.bbox.width), height=50)
+        # Avoid message_label expanding the toolbar size, and in turn expanding
+        # the canvas size. When the user defines a small figure size(e.g. 2x2),
+        # this will cause:
+        # 1. Figure size that is bigger than the user's expectation.
+        # 2. When message_label is refreshed by mouse enter/leave, the canvas
+        #    size will also be changed.
         self.pack_propagate(False)

timhoffm commented May 8, 2025

Copy link
Copy Markdown
Member

Basically yes. A bit clearer

... Without pack_propergate(False), when the user defines a small figure size(e.g. 2x2),

sandyowlet force-pushed the bugfix/issue-28330 branch from 4adcd17 to 185b4fa Compare May 9, 2025 16:45

QuLogic commented May 9, 2025

Copy link
Copy Markdown
Member

Did we also want to shrink the toolbar height, as noted in #28330 (comment)?

Copy link
Copy Markdown
Member

Did we also want to shrink the toolbar height, as noted in #28330 (comment)?

I'd be in favor of that.

sandyowlet commented May 19, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Did we also want to shrink the toolbar height, as noted in #28330 (comment)?

Sorry, I used to think this display issue was simply due to the height of the toolbar.
However, after testing in both Windows and Linux environments, it seems to be related to DPI scaling.

(windows)

(linux)

When the scaling is set to 150% on windows, canvas is resized to 300 * 300, but the toolbar is resized to 300 * 50.
And on linux, the canvas is resized to 300 * 300 and toolbar is resized to 300 * 75.

This makes the appearance on Windows as expected, but not on Linux.

I'm not very clear on how rescaling works with TkAgg. Does anyone have experience with this?

Copy link
Copy Markdown
Member

I'm not an expert on this, but the relevant starting point in our code base is here:

tacaswell modified the milestones: v3.10.4, v3.11.0 Jul 24, 2025

QuLogic commented Oct 31, 2025

Copy link
Copy Markdown
Member

I can't reproduce the toolbar issue on Linux regardless of DPI scaling setting. I'm going to merge as this does fix a long-standing problem.

QuLogic merged commit 53a5bc6 into matplotlib:main Oct 31, 2025
andreas16700 added a commit to andreas16700/matplotlib that referenced this pull request Jan 28, 2026
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: unstable tkagg small plot size window

5 participants


Back | FazBrowse Home | New Git URL