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

Replace quiver dpi callback with reinit-on-dpi-changed.#22807

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

Merged
greglucas merged 1 commit intomatplotlib:mainfromanntzer:qd
Apr 9, 2022

Conversation

anntzer
Copy link
Contributor

Instead of registering a callback to update itself whenever the dpi
changes, do the same thing as every other artist which depends on dpi
(e.g. FancyArrowPatch), i.e. update oneself as needed. We can still
save duplicate calculations by only doing the init if the figure dpi
changed compared to last time.

Also drop _new_UV, which is never read.

Closes#22804.

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

Instead of registering a callback to update itself whenever the dpichanges, do the same thing as every other artist which depends on dpi(e.g. FancyArrowPatch), i.e. update oneself as needed.  We can stillsave duplicate calculations by only doing the init if the figure dpichanged compared to last time.Also drop _new_UV, which is never read.
@greglucas
Copy link
Contributor

Nice! Thanks for the quick fix. I had just started looking into this as well and was going to change to using "resize_event" on the canvas which is what is really desired I think, but this is nicer :) On that note, I assume you realized that "dpi_changed" isn't used anywhere else in the codebase, so I would vote for deprecating that in another PR too... Ithinkresize_event should be thrown from the dpi_update function because if you change the dpi you are really resizing the canvas?

@jklymak
Copy link
Member

Not looking at the details, but should these things be done in trans_dpi_acale?

@QuLogic
Copy link
Member

I'm not sure that that would be possible as these are arrows positioned in data space, but whose size is determined by screen space.

@jklymak
Copy link
Member

We have this problem relatively often, at least with arrows - we want a glyph to have one dimension in data space, but the shape of the arrow heads in physical space. This doesn't seem too hard to do in physical space at draw time. Transfer the anchors to physical space and then draw the arrow and let its transform be physical space (for which we need a better name than trans_dpi_scale) if we do that dpi changes happen at the renderer level and the upper level code doesn't need a callback.

@jklymak
Copy link
Member

Is this only used for labelsep? Can we place text with an offset transform?

@@ -562,18 +525,19 @@ def _init(self):
"""
# It seems that there are not enough event notifications
# available to have this work on an as-needed basis at present.
if True: #notself._initialized:
if True: #self._dpi_at_last_init !=self.axes.figure.dpi
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change the comment? why does this code get run unconditionally?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I don't know why the original check got commented out (and don't really want to investigate right now), I'm just replacing _initialized by its newer moral equivalent.


def _init(self):
if True: # not self._initialized:
if not self.Q._initialized:
if True: # self._dpi_at_last_init != self.axes.figure.dpi
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why this condition is here if its always true?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

As above.

Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

This seems good. I still think quiver should not have a concept of dpi, but I think this change could go in before a significant refactoring. Definitely prefer this to a callback.

have you tested changing the dpi? I'm not even sure how we do that.

@anntzer
Copy link
ContributorAuthor

Agree that deprecating dpi_changed is perhaps a good idea, but this pr is really just aiming for the minimum fix. Ditto for using offset_transform or dpi_scale_trans instead.
No tests either for now :) (if anyone wants to contribute one...)

Copy link
Contributor

@greglucasgreglucas left a comment

Choose a reason for hiding this comment

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

I tested this on my multi-monitor mixed-dpi setup and it looks good to me. I think this is good to go for now and there are a few follow-up things that can be done in subsequent PRs.

@greglucasgreglucas merged commit1999228 intomatplotlib:mainApr 9, 2022
@anntzeranntzer deleted the qd branchApril 9, 2022 13:49
@greglucasgreglucas mentioned this pull requestApr 9, 2022
1 task
@QuLogicQuLogic added this to thev3.5.2 milestoneApr 11, 2022
@QuLogic
Copy link
Member

@meeseeksdev backport to v3.5.x

@lumberbot-app
Copy link

Could not push to auto-backport-of-pr-22807-on-v3.5.x due to error, aborting.

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestApr 11, 2022
@QuLogic
Copy link
Member

@meeseeksdev backport to v3.5.x

@lumberbot-app
Copy link

Could not push to auto-backport-of-pr-22807-on-v3.5.x due to error, aborting.

@QuLogic
Copy link
Member

meeseeksdev backport to v3.5.x

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestApr 13, 2022
oscargus added a commit that referenced this pull requestApr 13, 2022
…807-on-v3.5.xBackport PR#22807 on branch v3.5.x (Replace quiver dpi callback with reinit-on-dpi-changed.)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak left review comments

@QuLogicQuLogicQuLogic approved these changes

@greglucasgreglucasgreglucas approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.5.2
Development

Successfully merging this pull request may close these issues.

[Bug]: Quiver not working with subfigure?
4 participants
@anntzer@greglucas@jklymak@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp