Skip to content

Initial HiDPI support for qt5agg backend #6389

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
wants to merge 1 commit into from

Conversation

piannucci
Copy link
Contributor

Here's what needs to be done to get HiDPI support working with qt5agg. Not sure if you want to do it this way or some other way.

@tacaswell
Copy link
Member

The changes in qt5_backend.py seem un-related?

@tacaswell tacaswell added this to the 2.1 (next point release) milestone May 9, 2016
@mretegan
Copy link

On OSX 10.11 I get the following error:

File "/Users/marius/Library/Python/3.5/lib/python/site-packages/matplotlib/backends/backend_qt5.py", line 253, in mouseEventCoords
    x,y = self.mouseEventCoords(pos)
RecursionError: maximum recursion depth exceeded

@piannucci
Copy link
Contributor Author

piannucci commented May 13, 2016

Whoops. I typo'd that pretty badly when building the commit. The changes in the two files are related: if the dpi_ratio is not 1, then mouse events need to be mapped between device and pixel coordinates in order for the rest of the event stack to behave correctly.

Fixed some PEP8 violations.

@fariza
Copy link
Member

fariza commented May 16, 2016

Can this be done in a more general way? something that will be useful for all backends?

What about adding a FigureCanvasBase.get_device_pixel_ratio or something like that (returns 1 by default).
And the basic multiplication done in the FigureCanvasBase.xxxEvent instead that in the specific backend?

@astrofrog
Copy link
Contributor

It would be great to get a fix in for this, even if it is not a solution that is applicable to all backends. Currently for glue, everything looks nice and crisp, except the Matplotlib canvas, which looks pixellated (on a retina display).

@adrn
Copy link
Contributor

adrn commented Aug 28, 2016

Any progress on this? @astrofrog are you using the MacOSX backend in the meantime?

@tacaswell
Copy link
Member

@adrn This seems to have stalled. Can you test if this

@tacaswell
Copy link
Member

Sorry for partial message (UI fail: start typing, decide to 'powercycle' to re-trigger CI, close and post partial message)

@adrn Can you test if this works for qt5 + hidpi?

I could be convinced that this should be backported for 2.0 if it gets done in the next week or so.

@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.1 (next point release), 2.0.1 (next bug fix release) Aug 28, 2016
@mretegan
Copy link

mretegan commented Aug 30, 2016

@adrn For applications that embed the Matplotlib window, the MacOSX backend is not an option.

The only standing issue with this is the dpi used in the figure; it is still the default 100, even for Retina display. Maybe this should be scaled by devicePixelRatio? Other than that everything looks really nice and crisp. A print screen of a small app that uses the backend and the code used to make it. It would be really nice to have this in v2.0.

retina

@jenshnielsen
Copy link
Member

I think we should push for getting this into 2.0. I will see what I can do

@adrn
Copy link
Contributor

adrn commented Aug 30, 2016

@tacaswell I'll also take a look at this today.

@tacaswell
Copy link
Member

@adrn Can you coordinate with @jenshnielsen ?

@jenshnielsen
Copy link
Member

@adrn if you have time to work on it that is much appreciated, I will then make sure it is reviewed and merged.

@adrn
Copy link
Contributor

adrn commented Aug 30, 2016

@jenshnielsen Will try -- I'm at astrohackweek and will likely spend some hack time on this.

@jenshnielsen
Copy link
Member

Great if you need any assistance please just ask

@adrn
Copy link
Contributor

adrn commented Aug 30, 2016

Alright here's what I see. I compares (this PR + qt5agg) and (this PR + tkagg) using this code:

import numpy as np
import matplotlib as mpl
# mpl.rcParams['backend'] = 'tkagg'
# mpl.rcParams['backend'] = 'qt5agg'
import matplotlib.pyplot as plt

with plt.style.context('classic'):
    x = np.random.normal(size=128)
    y = np.random.normal(size=128)

    plt.scatter(x, y)
    plt.show()

qt5agg

tkagg

So it looks like the fix here works, but the fonts, markers, ticks, etc. need to be scaled by the pixel ratio?

@tacaswell
Copy link
Member

I think you just need to up the DPI passed to the renderer?

@jenshnielsen
Copy link
Member

#5383 which adds hidpi support to the notebook backend may give you some clues on how to do that.

@QuLogic QuLogic mentioned this pull request Nov 24, 2016
@QuLogic QuLogic assigned QuLogic and unassigned jenshnielsen Nov 24, 2016
@QuLogic
Copy link
Member

QuLogic commented Jan 4, 2017

Finished in #7507.

@QuLogic QuLogic closed this Jan 4, 2017
@QuLogic QuLogic modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants