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 independently of colorbar.#20949

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
jklymak merged 1 commit intomatplotlib:masterfromanntzer:smd
Sep 10, 2021

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedAug 30, 2021
edited
Loading

Currently (since#12459), when a colorbar is present, the cursor data under imshow() is
formatted using the colorbar's cursor formatter (the idea being that
that formatter should be able to "smartly" take normalization limits
into account); if no colorbar is present a fixed format string ("%0.3g")
is used (see#12473 for a stalled attempt to work around that).

In fact, there is a better scale that defines the number of significant
digits one should display in an imshow cursor data: it arises because
colormaps are discrete (usually with 256 colors, but in any case the
value is available ascmap.N). This quantization tells us, for a
given value, by how much one needs to move before the underlying color
changes (at all); that step size can be used to to determine a number
of significant digits to display. (Even if that's not necessarily
always the best number, it should at least be reasonablegiven the
user's choice of normalization
.)

Also, note that because ScalarFormatter has now changed to take pixel
size into account when determiningits number of significant digits (#16776),
the previous approach of relying on the colorbar formatter has become
a less good approximation, as that means that the number of digits
displayed for an imshow() cursor could depend on the physical size of
the associated colorbar (if present).

Also factor out and reuse some logic to compute the number of
significant digits to use in format strings for given value/error pairs,
already used by the linear and polar tickers.

PR Summary

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • 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).

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 makes sense to me.

@anntzeranntzerforce-pushed thesmd branch 2 times, most recently fromd280424 tob00423fCompareSeptember 8, 2021 12:26
@@ -297,3 +298,20 @@ def warn_external(message, category=None):
break
frame = frame.f_back
warnings.warn(message, category, stacklevel)


def g_sig_digits(value, delta):
Copy link
Member

Choose a reason for hiding this comment

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

This function is not API related. I think it should becbook._g_sig_digits.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure.

Currently, when a colorbar is present, the cursor data under imshow() isformatted using the colorbar's cursor formatter (the idea being thatthat formatter should be able to "smartly" take normalization limitsinto account); if no colorbar is present a fixed format string ("%0.3g")is used.In fact, there is a better scale that defines the number of significantdigits one should display in an imshow cursor data: it arises becausecolormaps are discrete (usually with 256 colors, but in any case thevalue is available as `cmap.N`).  This quantization tells us, for agiven value, by how much one needs to move before the underlying colorchanges (at all); that step size can be used to to determine a numberof significant digits to display.  (Even if that's not necessarilyalways the best number, it should at least be reasonable *given theuser's choice of normalization*.)Also, note that because ScalarFormatter has now changed to take pixelsize into account when determining *its* number of significant digits,the previous approach of relying on the colorbar formatter has becomea less good approximation, as that means that the number of digitsdisplayed for an imshow() cursor could depend on the physical size ofthe associated colorbar (if present).Also factor out and reuse some logic to compute the number ofsignificant digits to use in format strings for given value/error pairs,already used by the linear and polar tickers.
Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

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

Anybody can merge after CI pass.

@jklymakjklymak merged commit0666c59 intomatplotlib:masterSep 10, 2021
@jklymakjklymak added this to thev3.5.0 milestoneSep 10, 2021
@anntzeranntzer deleted the smd branchSeptember 10, 2021 08:26
@jklymak
Copy link
Member

@meeseeksdev backport to 3.5.x

@lumberbot-app
Copy link

Something went wrong ... Please have a look at my logs.

It seem that the branch you are trying to backport to does not exists.

@jklymak
Copy link
Member

@meeseeksdev backport to v3.5.x

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestSep 10, 2021
timhoffm added a commit that referenced this pull requestSep 10, 2021
…949-on-v3.5.xBackport PR#20949 on branch v3.5.x (Improve formatting of imshow() cursor data independently of colorbar.)
@anntzeranntzer mentioned this pull requestSep 21, 2021
7 tasks
tacaswell pushed a commit that referenced this pull requestOct 20, 2021
Improve formatting of imshow() cursor data independently of colorbar.
ericpre pushed a commit to ericpre/matplotlib that referenced this pull requestOct 20, 2021
Improve formatting of imshow() cursor data independently of colorbar.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.5.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@jklymak@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp