Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: when creating a canvas from a Figure use original dpi#30750

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
tacaswell wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromtacaswell:fix_hidpi_loop

Conversation

@tacaswell
Copy link
Member

PR summary

When we upscale the DPI for high-dpi screens we stash the original dpi and then set the figure dpi to the scaled version. If the same Figure instance is repeatedly passed to a Canvas that support hi-dpi it would go into a loop where the scaled DPI is treated as the original dpi and infinitely increases.

By grabbingfig._original_dpi (which we stash for exactly this reason) we can avoid this loop.

closes#26380

This is a slightly more general version of what we had already done to support re-attaching Figures to pyplot.

This is covered by the tests for dpi ratio tests we added as part of re-attaching to Figures to pyplot (which my first version of this broke so I'm sure it is being hit).

There is a case that we should move the "re run with device ratio 1" logic intoCanvasBase, but any backend that does support scaling will take care of re-scaling the canvas on display so setting it back to 1 inCanvasBase.__init__ seems like it will always be redundent for users and we have a hook to explicitly clean it up when we remove the Figure from pyplot.

I suspect there is still a few more iterations before we have covered all the stress-cases on this, but this is another step in the right direction.

PR checklist

When we upscale the DPI for high-dpi screens we stash the original dpi and thenset the figure dpi to the scaled version.  If the same Figure instance isrepeatedly passed to a Canvas that support hi-dpi it would go into a loop wherethe scaled DPI is treated as the original dpi and infinitely increases.By grabbing `fig._original_dpi` (which we stash for exactly this reason) we canavoid this loop.closesmatplotlib#26380
@anntzer
Copy link
Contributor

Maybe related to#27224? (I didn't actually check)

The issue is that we reset the dpi but did not re-compute any of thebounding boxes derived from the dpi leading to the initial redraw eventsto use the wrong physical size on the screen.Closesmatplotlib#27224
@tacaswell
Copy link
MemberAuthor

I found a clean place to test the second fix.

anntzer reacted with hooray emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@timhoffmtimhoffmtimhoffm approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

v3.11.0

Development

Successfully merging this pull request may close these issues.

[Bug]: DPI keeps doubling when creating a new MatPlotLib QtWidget in qt6

3 participants

@tacaswell@anntzer@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp