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

Improve formatting of imshow() cursor data when a colorbar exists.#12459

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
efiring merged 2 commits intomatplotlib:masterfromanntzer:imshow-cursordata
Dec 10, 2018

Conversation

anntzer
Copy link
Contributor

When a colorbar exists, use its formatter to format cursor data.
For example, after

imshow([[10000, 10001]]); colorbar()

currently the cursor data on either pixel is rendered as 1e4, but after
this patch it becomes 0.0+1e4 / 1.0+1e4, or 10000.0 / 10001.0 if
rcParams["axes.formatter.useoffset"] is set to False. (Even though
the version with the offset text may not be the most esthetic, it's
clearly more informative than the current behavior...)

It would be nice if this worked even for ScalarMappables that don't
have a colorbar; this may include extracting the Formatter selection
code out of the colorbar code into something generally applicable to
ScalarMappables, or just generating a hidden colorbar "on-the-fly" if
needed just for the purpose of getting its Formatter.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzeranntzer added this to thev3.1 milestoneOct 9, 2018

Only handles fully math and fully non-math strings.
"""
if s[:1] == s[-1:] == "$":
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to writeif s[0] == s[-1] == "$"

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

That was to handle empty strings as well (which do occur here if e.g. you disable offsettexts), but I realized this would still give the wrong result with s = "$". So I added an explicit check on len(s) instead.

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.

Looks good; needs tests, and an API note I think.

@anntzer
Copy link
ContributorAuthor

added whatsnew (it's not an API change) and test

When a colorbar exists, use its formatter to format cursor data.For example, after```imshow([[10000, 10001]]); colorbar()```currently the cursor data on either pixel is rendered as 1e4, but afterthis patch it becomes 0.0+1e4 / 1.0+1e4, or 10000.0 / 10001.0 if`rcParams["axes.formatter.useoffset"]` is set to False.  (Even thoughthe version with the offset text may not be the most esthetic, it'sclearly more informative than the current behavior...)It would be nice if this worked even for ScalarMappables that don'thave a colorbar; this may include extracting the Formatter selectioncode out of the colorbar code into something generally applicable toScalarMappables, or just generating a hidden colorbar "on-the-fly" ifneeded just for the purpose of getting its Formatter.
@anntzer
Copy link
ContributorAuthor

todo: confirm that nothing horrible happens with boundarynorms.

@anntzer
Copy link
ContributorAuthor

Actually one can just try withexamples/images_contours_and_fields/image_masked.py orexamples/images_contours_and_fields/image_annotated_heatmap.py: BoundaryNorms work just fine with this PR.

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

@jklymakjklymakjklymak left review comments

@efiringefiringefiring approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

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

Successfully merging this pull request may close these issues.

4 participants
@anntzer@efiring@jklymak@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp