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
Low quality matplotlib inline plots on hidpi display #9148
Comments
@dalthviz, please take a look at this one. We need to add a new option in the Inline backend section of our preferences called
And pass that option to the kernel. |
using Kubuntu 18.10 installation there is no such a problem even with default png backend inline format |
Then I'd say it's a Qt issue and not an Spyder one. |
If this is still a correction needed, why not make it a default (instead of adding the option?) |
Because in non-HDPI screens plots will look huge. |
Got it thanks! Is there an overall High DPI setting for spyder? Could we link to that one? |
There's what Rafa added in
But linking both things (a change in that option with a change in the inline backend) is not work for Spyder 3. Should we leave this for Spyder 4? It's not that critical. |
Yes, I believe is the right place to fix it. |
There are similar issues with Gwenview PNG images opened in Kubuntu 18.10 HIDPI monitor with desktop scaled to fractional scale as in Spyder running on Mint 19.1. PNG images in Gwenview once opened looked exactly blurry and jagged and that issue is known and reported. |
@goanpeca, do you need to activate our option in
in your Retina Display Mac for things to look good there? That's to know if Qt adjusts automatically to HiDPI in some cases (like macOS). If you don't need to activate that option, then we really need to add another option to the console preferences (as proposed at the beginning) to tell the kernel that Spyder is running in a HiDPI screen. |
Some useful links:
|
This discussion runs over several years and it's not clear to me what needs to be done now. This is my understanding of the current situation. The images in the plots pane can be fixed by increasing the resolution (DPI) in the preferences, so the only thing that we maybe need to do is to change the default resolution, perhaps by taking the high-DPI scaling factor into account. The images in the IPython console can not be fixed by increasing the DPI in the preferences, because this will simply enlarge the image and the resolution remains the same. One possible fix here is to support the "Retina" format for plots like Jupyter, along the lines of PR #12128. However, that is a bit of a kludge. |
In fact, I think that would be the simplest thing to do, i.e. allow users to control the retina display option with a Spyder one. To do that, I propose the following:
|
I have now a slightly better idea what the "Retina" format for plots does. It changes two things: it doubles the matploblib resolution (in dpi) from what the user sets, and it shrinks plots in the IPython console by a factor of two. In more detail, the standard settings are for plots to be 6 inches wide and 4 inches high with a resolution of 72 dpi. This produces images of 6 * 72 = 432 pixels wide and 4 * 72 = 288 pixels high (actually, the images are slightly smaller if tight layout is enabled, which it is by default). If the plot is displayed in the IPython console (which if the option "Mute inline plotting" is unchecked), then it is displayed as an image of 432x288 pixels. By default, the plot is displayed in the Plot pane with "Fit plots to window" checked. If the area where the plot is displayed is bigger than 432x288 (which corresponds to the Spyder window being bigger than about 1000x800 pixels), then the image is magnified and since it is PNG that will give a low quality plot. If the user turns on retina (which can currently be done with So at least for me, retina does not improve the appearance in the IPython console and while is does improve the appearance in the Plots pane, the same effect can be achieved more transparently by increasing the DPI value in the Spyder preferences. |
Ok, thanks for the analysis @jitseniesen. Could post a screenshot of how plots look with an increased DPI (the one you consider it'd really improve things) in the console and Plots pane? |
Here is a plot in the Plots pane in the default resolution of 72 dpi. I reconfigured the layout on Spyder somewhat to make the Plots pane bigger so that the difference is more apparent on my monitor (1920 x 1080 pixels). This corresponds on what would happen in the default layout if your monitor is 2560 x 1440 or thereabouts. The picture is shown with a zoom factor of 213% which makes it not sharp. This is what is looks like in the IPython console. The console does not zoom so the picture is always sharp, but small. If we double the resolution of the plots to 144 dpi, it is displayed with a zoom factor of 107% and looks quite sharp. The IPython console does not zoom so the image is twice as big: Increasing the DPI is not free, it makes the pictures bigger and thus that costs more memory. The PNG of the plot with 144 dpi is 29 kB, so if you have 100 plots that makes 2.9 MB, which by itself seems quite okay. There is probably more overhead, which might be substantial and thus cause problems, but I don't know. If we don't care about memory and we want most users to get sharp images, I propose to increase the default DPI in Spyder so that plots on a fairly typical but high-end monitor are displayed with a zoom factor of around 100%. If we use 4K monitors as our reference, their resolution is 3840 x 2160. I estimate that the area in the Plots display for showing the actual plot is about 1700 x 900. With a default plot height of 4 inches, that suggests a resolution of 225 dpi. For comparison, the current default in Spyder is 72 dpi and in Matplotlib it is 100 dpi. An alternative is to do what the IPython console does and not zoom in, this corresponds to having the option "Fit plots to window" unchecked by default (it is now checked by default). This should help with users complaining that the plot is not sharp, but instead we will get users complaining that the plot is too small. Final note, I don't have a true hi-dpi monitor so I can't test that. |
Just a quick note to say that agree with this decision. |
Issue Report Checklist
conda update spyder
(orpip
, if not using Anaconda)jupyter qtconsole
(if console-related)spyder --reset
Problem Description
What steps reproduce the problem?
What is the expected output? What do you see instead?
Expected the output to be smooth high quality DPI inline plot after change in inline figure format but instead blurry jagged low quality version is displayed as before
Jupyter notebook run shows correct smooth plot after inline figure format change
Versions
Dependencies
The text was updated successfully, but these errors were encountered: