FIX: Qt5 account for dpiratio as early as possible#9002
Merged
efiring merged 2 commits intomatplotlib:masterfrom Aug 14, 2017
Merged
FIX: Qt5 account for dpiratio as early as possible#9002efiring merged 2 commits intomatplotlib:masterfrom
efiring merged 2 commits intomatplotlib:masterfrom
Conversation
Previously, the canvas size would get set to too small because - in the FigureCanvasQt.__init__ `get_width_height` is used to set the initial size of the canvas - `get_width_height` accounts for the dpiratio, but it has not been multiplied up yet so it reports half the size it should - this get propagated back down into the Figure object in the resize method - the dpi is then scaled up This fix - moves adding the `_original_dpi` attribute to the Figure as soon as possible in the base __init__ - calls `_update_dpi` before asking the figure how big it is Closes matplotlib#8717
Contributor
|
I'll test this out this afternoon with my mixed resolution screen set-up |
Contributor
|
I won't be able to do proper reviews in the coming days due to spotty internet access, so please carry on without me. If someone is really courageous they can check how PRs such as this one interact with #8771 (cairo/qt5) and/or try to fix #8659 (causing some Qt-related tests to be skipped in some cases). |
astrofrog
approved these changes
Aug 7, 2017
Contributor
astrofrog
left a comment
There was a problem hiding this comment.
This looks good and still works for me. Stylistically I find it unusual to have _update_figure_dpi before __init__ in FigureCanvasQT, but this is ultra-minor.
The values in the test were the buggy values. We expect a (5, 2) in figure at 120 dpi to be (600, 240) screen pixels.
Member
Author
|
Turns out the number in the test were low due to the bug that this is fixing! |
dopplershift
approved these changes
Aug 14, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the canvas size would get set to too small because
get_width_heightis used to setthe initial size of the canvas
get_width_heightaccounts for the dpiratio, but it has not beenmultiplied up yet so it reports half the size it should
method
This fix
_original_dpiattribute to the Figure assoon as possible in the base init
_update_dpibefore asking the figure how big it isattn @djpine