Skip to content

Low quality window plots on hidpi display #17440

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

Closed
chesnokov-yuriy opened this issue May 18, 2020 · 14 comments
Closed

Low quality window plots on hidpi display #17440

chesnokov-yuriy opened this issue May 18, 2020 · 14 comments
Milestone

Comments

@chesnokov-yuriy
Copy link

Bug report

Bug summary

Executing python script with line plotting code from command line on a hidpi 4k resolution display produces low quality UI window plot.

Code for reproduction

$ python3 plot.py

plot.py file contents:

from numpy import random

import matplotlib as mpl
import matplotlib.pyplot as pp

print(mpl.__version__)
print(mpl.get_backend())

pp.figure()
pp.plot(random.randn(250))
pp.grid()
pp.show()

Actual outcome

plot-lowdpi

3.2.1
Qt5Agg

Expected outcome

Expected high quality UI window plots as in Spyder IDE running on the same machine

plot-hidpi

or similar high quality UI window plots from command line in the previous Kubuntu 19 with matplotlib 3.0.3 and Python 3.7

Matplotlib version

  • Operating system: Kubuntu 20.04
  • Matplotlib version: 3.2.1
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8.2
  • Jupyter version (if applicable):
  • Other libraries:
@timhoffm
Copy link
Member

This is likely addressed by #15656.

What is the display scaling factor you are using? (probably something between 1 and 2)?

@chesnokov-yuriy
Copy link
Author

chesnokov-yuriy commented May 18, 2020

exactly, if there was some change from 3.0.3 version which worked correctly on Kubuntu 19

screen

currently, on updated Kubuntu 20.04 even previously running correctly 3.0.3 version is no longer working

@tacaswell
Copy link
Member

@chesnokov-yuriy If you change your scaling does it get better? I agree with @timhoffm this is likely due to Qt growing the ability to do fractional scaling under us.

@chesnokov-yuriy
Copy link
Author

@tacaswell let me try any different scaling and investigate #15656

Kubuntu 19 + matplotlib 3.0.3 command line plot.py: high quality
Kubuntu 19 + matplotlib 3.0.3 Spyder IDE plot: high quality
Kubuntu 19 + matplotlib 3.0.3 Jupyter notebook plot: high quality

on Kubuntu 20.04 situation became different somehow

Kubuntu 19 + matplotlib 3.0.3 command line plot.py: low quality
Kubuntu 19 + matplotlib 3.2.1 command line plot.py: low quality
Kubuntu 19 + matplotlib 3.2.1 Spyder IDE plot: high quality
Kubuntu 19 + matplotlib 3.2.1 Jupyter notebook plot: high quality only after %config InlineBackend.figure_format = 'retina'
Kubuntu 19 + matplotlib 3.2.1 IPython plot: low quality even after %config InlineBackend.figure_format = 'retina'

Only Spyder IDE produces high quality plots both inline and in QtAgg5 UI window even without any 'retina' settings

@timhoffm
Copy link
Member

@chesnokov-yuriy do you know which Qt version each of the call uses?

Remarks:

  • The effect is definitively dependent on the backend. In the original post, you should a window from the Qt backend.
  • The inline backend in jupyter notebook is another piece of cake (though it might as well struggle with fractional magnifications).
  • The InlineBackend config does not have an effect for IPython, because IPython cannot use the inline backend. It will likely also use the Qt backend.
  • For spyder: do you pop up the plot in a separate window or is the plot integrated in the
    Spyder IDE window?

@chesnokov-yuriy
Copy link
Author

chesnokov-yuriy commented May 19, 2020

@timhoffm I do not remember which Qt was in Kubuntu 19.10 or 19.04 and which Plasma if only looked up from release specifications. Kubuntu 20.04 Qt is 5.12.8 Kde Plasma 5.18.4

Spyder 4.1.3 provides high quality plots in either inline or Qt5Agg without any additional settings
spyder
preferences

@chesnokov-yuriy
Copy link
Author

as IPython QtConsole is in low quality
ipython

@chesnokov-yuriy
Copy link
Author

@chesnokov-yuriy If you change your scaling does it get better?

display configuration settings global scale 100%: high quality plot

scale1 0

display configuration settings global scale 125%: low quality same as 150% sa reported before

@chesnokov-yuriy
Copy link
Author

@chesnokov-yuriy do you know which Qt version each of the call uses?

Kubuntu 19.10 Qt 5.12.4 Python 3.7
Kubuntu 20.04 Qt 5.12.8 Python 3.8

@tacaswell
Copy link
Member

display configuration settings global scale 100%: high quality plot

That tracks really well with @timhoffm 's theory that this is related to us not handling the fractional scaling correctly.

@tacaswell tacaswell added this to the v3.3.0 milestone May 20, 2020
@chesnokov-yuriy
Copy link
Author

qapp.py file

from matplotlib.backends.qt_compat import QtWidgets

qApp = QtWidgets.QApplication([])

print('  logical dpi:', qApp.desktop().logicalDpiX())
print(' physical dpi:', qApp.desktop().physicalDpiX())
print('        width:', qApp.desktop().screenGeometry().width())
print('       height:', qApp.desktop().screenGeometry().height())

bash shell environment

$ printenv | grep QT_
QT_ACCESSIBILITY=1
QT_SCREEN_SCALE_FACTORS=HDMI-1=1.5;HDMI-2=1.5;DP-1=1.5;
QT_AUTO_SCREEN_SCALE_FACTOR=0

display configuration: 150% scale with 3840x2160

$ python3 qapp.py
  logical dpi: 96
 physical dpi: 108
        width: 2560
       height: 1440

adding QT_SCALE_FACTOR environment variable set to 0.666667 which is 100/150%

$ QT_SCALE_FACTOR=0.666667 python3 qapp.py
  logical dpi: 96
 physical dpi: 163
        width: 3840
       height: 2160

using the same QT_SCALE_FACTOR set before plot.py call results in high quality plot with tiny toolbar and status bar, which looks much better though than default large margins

$ QT_SCALE_FACTOR=0.666667 python3 plot.py

plot

@tacaswell
Copy link
Member

This issue should not block tagging the release candidate.

@tacaswell tacaswell modified the milestones: v3.3.0, v3.2.2 Jun 11, 2020
@QuLogic
Copy link
Member

QuLogic commented Jun 15, 2020

Is this fixed by #15656?

@tacaswell
Copy link
Member

Yes, it should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants