-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Scaling issue with 4K panel! #12221
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
We'd need a lot more information before we can tell if this is a bug or not. Thanks! |
I recently purchased a new pc laptop with 4K resolution touch screen. when I run the following code while screen is at native max resolution of 4K. pyplot images and font sizes are displayed very tiny!!
But when I lower the screen resolution to FHD, 1920x1080 in the windows setting, the figures and font sizes becomes normal and good! So, my question is how I can configure matplotlib to plot similarly both in UHD or FHD without the need to make changes in the code or use dragging. Please check the screen resolution in the code output shown in both figures above!. Dragging only makes plot bigger but font size of tick labels stay the same, unless I change them in the code |
Qt5Agg should automatically detect if the screen dpi is doubled. It calls If you want to set the dpi by hand, you can set the If you want to debug, you can edit backend_qt5agg and put some print statements in |
I think there is a fundamental difference between macOS and the rest of the world (or between HighDPI and high dpi). Macs may scale the dpi, effectively showing the application in a virtual dpi space. Windows does not do that. There is just one dpi; but it might instead use different profiles such that some relevant metrics are scaled by a constant factor (e.g. a 12pt font will become 24pt). I suppose this article is relevant here. Possibly this blog post as well. It was also reported that on windows One might think about making the For the time being the only option seems to be to change the true dpi, e.g. in this case the rc file may be changed to
|
@ImportanceOfBeingErnest Thank you very much. actually |
Reopening, because this is surely a desireable feature, given that matplotlib goes through all the trouble of using different dpi values on different levels, but apparently only mac users will benefit from it. |
I actually thinks it’s a pain that the Mac does this rather than just stating its true dpi. The advantage of allowing it to change is dragging between screens w different dpi. But in my opinion we should just get the dpi from the device at draw time. |
There was a similar issue in spyder ide but recently solved in their latest releases. Spyder is basically using Qt5. I experienced scaling issue with spyder using 4K screen but resolved by enabling spyder-ide/spyder#4316 |
Thanks - so far as I can see we already do "Case II" in the blog post about QT above: matplotlib/lib/matplotlib/backends/backend_qt5.py Lines 127 to 130 in 2125562
So its odd that its not working for Qt5, unless you have an old Qt5, an environment variable set, or are somehow disabling this. You could download master and put a print statement above to see if your Qt5 has the correct attribute. |
I modified the file in my current python installation folder as shown below. could not manage to build matplotlib from master! saying
it prints the correct resolution whenever plotting any figures |
To better understand what's going on, can you please also check the values of
|
output:
|
sorry typo phyiscal -> physical |
output
|
I solved the the problem by installing python from python.org website rather than anaconda/miniconda. matplotlib installed using pip. The backend is TkAgg and matplotlib version is 3.0.0. However, when changing the backend to Qt5Agg, scaling issue appears again!. To me backend does not matter as long as the plotted figures are in appropriate scale!! |
Does the documentation at https://doc.qt.io/qt-5.9/highdpi.html#operating-system-support help at all? |
I just tested this in Spyder. Using their settings makes their GUI look better, but the plots don't really get any better. If you are plotting inline (inside of their app) the plot gets bigger, but more blurry (I think the image just gets scaled up). When you change the settings to use the QT5 backend (and the plot opens in a separate window) it is still tiny. |
Just to be clear, spyder does not change any matplotlib variables. The issue for spyder being mentionned in this thread is because their interface is based on QT as well, and hence any solution they have used might help with this issue. This being said, @w1res if you experience the same issue, can you share as accurate as possible your system/version/windows graphics/dpi settings? |
I unfortunately returned the unit since I experienced some other issues with the laptop. Therefore, I apologise if not being able to provide any further testing with any 4K monitor since there is none I have now. My apologies to all of you. |
I'm using a laptop with a 3840 x 2160 (4K) touch screen. The operating system is Windows 10 Pro version 1803. I'm using 200% scaling (default was 250%) in the operating system settings. My graphics card is the NVIDIA GTX 1050 TI. |
Note that latest Qt is not available in conda-forge. This means you will not get good behaviour if running with fractional DPI. However, there appears to be some movement on the above issue for updating PyQt in conda-forge. |
It depends on which screen I run the command from. If I run it from my high DPI laptop I get 2, if I run it from the external window I get 1. I also noticed that somehow the plotting got better. In this GIF you can see the effect of running
However, the version before running this line is also pretty readable. I will update you if I notice any strange behavior. PS: This is not my whole screen that you see in the GIF |
One more odd test, can you please use fig.set_size_inches(5, 5) and then use a ruler to measure the size of the window on your screen in all of these cases? If you move the window between the low and high DPI screens does it resize in a reasonable way? |
Sorry for the delay. I noticed that in my first call after restarting my high-DPI laptop, the scaling is off and the figure is very small. When I run the line Then I run Finally, when I close my Jupyter terminal or restart VS Code, I get a plot that is nicely scaled without needing to rerun I hope this helps you with the troubleshooting. |
@tacaswell @QuLogic any news? |
For what it's worth I just got a 4k laptop and noticed that same thing with the Qt backend. Not sure what the status is, but e.g. Spyder is working well (although I had to enable a switch in the preferences to have it scale properly). Given time, I can have a more in depth look at this now... |
Spyder refers to https://doc.qt.io/qt-5/highdpi.html The setting that made it work for me ends up like this in the code QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling,
CONF.get('main', 'high_dpi_scaling')) I think a solution is to do something similar through a boolean RC param? (Although this may of course break some of the other fixed high DPI issues...) |
Direct links: Edit: sorry for the spamming. I missed many of the earlier discussions... |
Are there any news regarding this issue? Still having high-DPI related problems on VS Code and I need to paste a chunk of code in the beginning of each script to overcome the issue. Thank you! |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Matplotlib plots and font size looks very small on 4K monitor.
Is there away to automatically enable high DPI?
The text was updated successfully, but these errors were encountered: