-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Invalid pixel ratio update when changing screen resolution #19656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As a follow-up, if I add the following code when I create a new
Edit: I might have spoken too soon. It seemed to fix it in initial tests, but the problem is recurring now, although I can always manually force a call to |
Is this still an issue with Matplotlib 3.6? There were some improvements to HiDPI scaling since version 3.4, so there's a chance this might have been fixed since originally reported. |
In NeXpy, I fixed this a long time ago by calling |
I think it has been fixed now in version 3.6.2. I commented out the call to Thanks for asking the question. I will probably keep the call to |
👍 |
Bug report
Bug summary
When switching from an external monitor, with a dpi ratio of 1.0, to my MacBook Pro laptop, with a dpi ratio of 2.0, existing PyQt windows containing Matplotlib plots look fine after waking from sleep but switch to a quarter size as soon as I select the window, i.e., the fix in the PR #19123 doesn't seem to work in this scenario.
Code for reproduction
I am using the NeXpy package, which embeds Matplotlib canvases in separate PyQt5 windows. Each window is added to a dictionary, called

plotviews
, which is available to an embedded Python shell. If I initially plot on my external monitor, I get the following plot:In the shell, I see the following ratios.
Actual outcome

When I switch to my laptop, the plots look fine initially, but as soon as I select any window, the plot shrinks to quarter size:
After the plots have shrunk, the
_dpi_ratio_prev
has still not been updated.Expected outcome
Obviously, the plots should not change size. Selecting the window does not appear to trigger the canvas
showEvent
function. I'm not sure what does. If I force an update, the plot does expand to the correct size. Note that_dpi_ratio_prev
has been updated after the explicit call to_update_screen
but only for the third figure. The others are still shrunk.I wonder if the
screenChanged
signal should be connected to_update_screen
at an earlier stage in initializing the window without depending on a call toshowEvent
.Matplotlib version
I used pip to update to the latest release candidate within a conda environment.
Edited to correct reference to the screen.
The text was updated successfully, but these errors were encountered: