Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tacaswell
Copy link
Member

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

attn @djpine

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
@tacaswell tacaswell added this to the 2.1 (next point release) milestone Aug 7, 2017
@tacaswell tacaswell requested review from anntzer and astrofrog August 7, 2017 04:33
@astrofrog
Copy link
Contributor

I'll test this out this afternoon with my mixed resolution screen set-up

@anntzer
Copy link
Contributor

anntzer commented Aug 7, 2017

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).

Copy link
Contributor

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Aug 7, 2017
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.
@tacaswell
Copy link
Member Author

Turns out the number in the test were low due to the bug that this is fixing!

@efiring efiring merged commit 805d20c into matplotlib:master Aug 14, 2017
@tacaswell tacaswell deleted the fix_qt5_dpi_no_manager branch August 15, 2017 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants