Skip to content

Fix tiny wx plot window on wxPython 4.3 - #32158

Merged
QuLogic merged 1 commit into
matplotlib:mainfrom
adarshsm:fix/32143-wx-tiny-window
Aug 5, 2026
Merged

Fix tiny wx plot window on wxPython 4.3#32158
QuLogic merged 1 commit into
matplotlib:mainfrom
adarshsm:fix/32143-wx-tiny-window

Conversation

@adarshsm

@adarshsm adarshsm commented Aug 1, 2026

Copy link
Copy Markdown

PR summary

Fixes #32143 — with wxPython 4.3 / 4.3.1 the WxAgg plot window opens tiny (~132×131) and must be manually resized; wxPython 4.2.5 is unaffected.

Cause

In FigureFrameWx.__init__ (lib/matplotlib/backends/backend_wx.py):

self.canvas.SetInitialSize(self.FromDIP(wx.Size(w, h)))  # sets size AND min size to (w, h)
self.canvas.SetMinSize(self.FromDIP(wx.Size(2, 2)))      # resets min size to (2, 2)
self.canvas.SetFocus()

self.Fit()                                               # sizes the frame from the canvas

SetInitialSize(w, h) sets both the size and the min size to (w, h), but the next line resets the canvas min size to (2, 2), and only then is Fit() called. wxPython 4.3 tracks wxWidgets 3.3, where Fit() sizes the frame from the canvas's current min size — so the (2, 2) reset collapses the window. wxPython 4.2.5 (wxWidgets 3.2) honoured the initial size instead.

Fix

Call Fit() while the canvas min size is still the initial (w, h), then relax it to (2, 2) afterwards so the window can still be resized smaller.

Testing

This is GUI-backend window sizing, which isn't covered by the automated suite. The issue reporter tested this exact reorder and confirmed it:

Thanks a lot for investigating. I can confirm that this works!

#32143 (comment) (and their confirmation).

`FigureFrameWx.__init__` called `canvas.SetInitialSize(w, h)` (which sets
both the size and the min size to (w, h)), then immediately reset the min
size to (2, 2), and only then called `self.Fit()`. With wxPython 4.3
(wxWidgets 3.3) `Fit` sizes the frame from the canvas's current min size,
so the (2, 2) reset collapsed the window to a tiny size that had to be
manually resized; wxPython 4.2.5 was unaffected.

Call `Fit()` while the canvas min size is still the initial (w, h), then
relax it to (2, 2) so the user can still resize the window smaller. The
reporter confirmed this resolves the tiny-window behaviour on wxPython 4.3.

Fixes matplotlib#32143
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

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. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on discourse chat 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.

@adarshsm

adarshsm commented Aug 1, 2026

Copy link
Copy Markdown
Author

Heads up on the one red check: codecov/patch is failing because the change is in FigureFrameWx.__init__, which is wx GUI-backend code that CI can't exercise for coverage — so the reordered lines report 0% patch coverage. Those two statements (self.Fit() and the SetMinSize call) were already uncovered before this PR; the change only reorders existing lines rather than adding new untested logic.

I don't think a regression test is feasible here: the bug only manifests on wxPython 4.3 (wxWidgets 3.3) with a real display. On the wx 4.2.x available in CI, both the old and new ordering produce a correctly-sized window, so a test would pass regardless of the fix and wouldn't actually guard the regression. The verification is the issue reporter confirming the reorder resolves the tiny-window behaviour on wx 4.3 (#32143). Happy to adjust if you'd prefer a different approach.

@QuLogic QuLogic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't test, but seems reasonable if the original reporter confirmed it worked.

@QuLogic QuLogic added this to the v3.11.2 milestone Aug 5, 2026
@QuLogic
QuLogic merged commit 046e0ed into matplotlib:main Aug 5, 2026
40 of 41 checks passed
timhoffm added a commit that referenced this pull request Aug 5, 2026
…158-on-v3.11.x

Backport PR #32158 on branch v3.11.x (Fix tiny wx plot window on wxPython 4.3)
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]: tiny plot window opens with wxPython 4.3

3 participants