One of the nice things about Qt5 (as far as I understand) is that it provides better support for HiDPI (retina) displays, but at the moment it doesn't look like Matplotlib is taking advantage of this:
PyQt4:
PyQt5:
MacOS X:
Note that MacOS X does take advantage of the HiDPI display, though the icons are still low-res
Interestingly, the low resolution pixels in the PyQt5 example look crisper which suggests that it might be rendered at HiDPI but the content of the canvas is low resolution.
So just to clarify, I think there are two issues here:
Is this in master or the latest release? I know some work has been done at
least in the macosx backend, and I could have sworn we fixed a few retina
issues in other backends. Not to say that we support retina everywhere, but
rather that we fixed some rendering issues on retina displays (things were
showing up a 4x the normal size and such).
As for the icons, it might be that they aren't high resolution enough to
really fare much better?
One of the nice things about Qt5 (as far as I understand) is that it
provides better support for HiDPI (retina) displays, but at the moment it
doesn't look like Matpotlib is taking advantage of this:
Interestingly, the low resolution pixels in the PyQt5 example look crisper
which suggests that it might be rendered at HiDPI but the content of the
canvas is low resolution.
—
Reply to this email directly or view it on GitHub #4977.
@WeatherGod - this is in master. The MacOS X backend does look nicer, though the icons there are still low DPI. I've updated the issue above to make this clearer and made the screenshots larger to show part of the canvas.
I'm going to open a separate issue for the icons to make sure this issue is about PyQt5 [update: see #4978]
changed the title [-]Improve resolution of output on HiDPI with PyQt5 backend[/-][+]Improve resolution of canvas on HiDPI with PyQt5 backend[/+]on Aug 22, 2015
As I understand it, part of the difficulty here is that there seem to be several layers trying to compensate for this issue.
On my laptop (linux and qt4agg) which has a stupidly high resolution screen the default settings render so that text is almost unreadable, but setting rcparams['figure.dpi'] = 150 seems to work well. Why this isn't the actual dpi of the screen or if this will work on mac + qt5 I don't know.
I am pretty sure that under the hood of the *Agg backends we are copying from the Agg pixel buffer to what ever the backends version of a screen buffer is (so we have per-pixel control and the gui doesn't do any interpolation). We really should sort out how to query the gui frameworks for things like screen DPI and update the figure.dpi parameter accordingly.
Just for the record, if I set rcparams['figure.dpi'] = 150 on Mac with Qt5, it just makes the figure larger rather than actually improving the resolution.
For the MacOSX backend, it's easy to fix the button icon resolution, provided that the image is available at a high enough resolution (either as a .png or as a .pdf).
you end up with a figure at full DPI resolution with smooth text, and the figure is no larger than it is with the lower DPI? On Mac this just makes the figure bigger and the DPI stays the same.
I looked at the backend code for Qt5 but couldn't see where there might be a Mac/Linux difference.
By the way, this is also the case on other Mac backends - changing the DPI just changes the figure size, which seems... wrong. Is that a bug?
No, on a high dpi screen my figures show up as tiny, increasing the DPI makes the font readable. I think that this is a result of my system not trying to compensate for the high dpi by bumping up the mpl dpi, it comes closer to what it really is, so a 5x6 figure really is 5x6 on the screen.
@astrofrog I get the same behaviour as you using the Qt5Agg backend and that rcParams. If I use the MacOSX backend with dpi=150 the figure is also bigger (and resolution is good), but the aspect ratio of the enlarged figure is different to the Qt5Agg.
I've been making progress on this, but in the process got very confused about the DPI issue and the fact that on most computers I've tried, DPI doesn't mean actual DPI but is just a multiplicative factor for figure size. So basically the question is whether a figure with a DPI of 80 should look crisp by default with PyQt5. I've sent a message for discussion to the dev list: https://mail.python.org/pipermail/matplotlib-devel/2015-September/000097.html
On Windows, using the TkAgg backend, Both the plotting canvas and the icons in the toolbar have low resolution, too :(
I am using the current 1.5.1 release, Python 3.5.1 and Windows 10.
Activity
WeatherGod commented on Aug 22, 2015
Is this in master or the latest release? I know some work has been done at
least in the macosx backend, and I could have sworn we fixed a few retina
issues in other backends. Not to say that we support retina everywhere, but
rather that we fixed some rendering issues on retina displays (things were
showing up a 4x the normal size and such).
As for the icons, it might be that they aren't high resolution enough to
really fare much better?
On Sat, Aug 22, 2015 at 10:03 AM, Thomas Robitaille <
notifications@github.com> wrote:
astrofrog commented on Aug 22, 2015
@WeatherGod - this is in master. The MacOS X backend does look nicer, though the icons there are still low DPI. I've updated the issue above to make this clearer and made the screenshots larger to show part of the canvas.
I'm going to open a separate issue for the icons to make sure this issue is about PyQt5 [update: see #4978]
tacaswell commented on Aug 22, 2015
As I understand it, part of the difficulty here is that there seem to be several layers trying to compensate for this issue.
On my laptop (linux and qt4agg) which has a stupidly high resolution screen the default settings render so that text is almost unreadable, but setting rcparams['figure.dpi'] = 150 seems to work well. Why this isn't the actual dpi of the screen or if this will work on mac + qt5 I don't know.
I am pretty sure that under the hood of the *Agg backends we are copying from the Agg pixel buffer to what ever the backends version of a screen buffer is (so we have per-pixel control and the gui doesn't do any interpolation). We really should sort out how to query the gui frameworks for things like screen DPI and update the figure.dpi parameter accordingly.
astrofrog commented on Aug 22, 2015
Just for the record, if I set rcparams['figure.dpi'] = 150 on Mac with Qt5, it just makes the figure larger rather than actually improving the resolution.
mdehoon commented on Aug 23, 2015
For the MacOSX backend, it's easy to fix the button icon resolution, provided that the image is available at a high enough resolution (either as a .png or as a .pdf).
mjsu commented on Sep 9, 2015
It would be great to fix this. I wish I had the skills to do so.
astrofrog commented on Sep 13, 2015
@tacaswell - so just to make sure I understand, on Linux with PyQt5, if you do:
you end up with a figure at full DPI resolution with smooth text, and the figure is no larger than it is with the lower DPI? On Mac this just makes the figure bigger and the DPI stays the same.
I looked at the backend code for Qt5 but couldn't see where there might be a Mac/Linux difference.
By the way, this is also the case on other Mac backends - changing the DPI just changes the figure size, which seems... wrong. Is that a bug?
tacaswell commented on Sep 14, 2015
No, on a high dpi screen my figures show up as tiny, increasing the DPI makes the font readable. I think that this is a result of my system not trying to compensate for the high dpi by bumping up the mpl dpi, it comes closer to what it really is, so a 5x6 figure really is 5x6 on the screen.
astrofrog commented on Sep 14, 2015
@tacaswell - ok, so it seems the machinery should be in place to get high resolution canvases, but it is just buggy on Mac, right?
Can anyone confirm whether they see the same behavior as me on Mac?
astrofrog commented on Sep 14, 2015
I think I found a path to a fix. I can work on it during the week but if anyone else knows the exact fix, please let me know!
mjsu commented on Sep 14, 2015
@astrofrog I get the same behaviour as you using the Qt5Agg backend and that rcParams. If I use the MacOSX backend with dpi=150 the figure is also bigger (and resolution is good), but the aspect ratio of the enlarged figure is different to the Qt5Agg.
astrofrog commented on Sep 19, 2015
I've been making progress on this, but in the process got very confused about the DPI issue and the fact that on most computers I've tried, DPI doesn't mean actual DPI but is just a multiplicative factor for figure size. So basically the question is whether a figure with a DPI of 80 should look crisp by default with PyQt5. I've sent a message for discussion to the dev list: https://mail.python.org/pipermail/matplotlib-devel/2015-September/000097.html
johan12345 commented on Mar 17, 2016
On Windows, using the TkAgg backend, Both the plotting canvas and the icons in the toolbar have low resolution, too :(
I am using the current 1.5.1 release, Python 3.5.1 and Windows 10.
piannucci commented on May 9, 2016
Here's a patch. Doesn't fix the icons, just the plots. #6389
QuLogic commented on Jan 4, 2017
Fixed by #6387 / #7507.