Improve formatting of imshow() cursor data when a colorbar exists.#12459
Merged
efiring merged 2 commits intomatplotlib:masterfrom Dec 10, 2018
Merged
Improve formatting of imshow() cursor data when a colorbar exists.#12459efiring merged 2 commits intomatplotlib:masterfrom
efiring merged 2 commits intomatplotlib:masterfrom
Conversation
4481b0c to
02a0455
Compare
timhoffm
reviewed
Oct 9, 2018
lib/matplotlib/cbook/__init__.py
Outdated
|
|
||
| Only handles fully math and fully non-math strings. | ||
| """ | ||
| if s[:1] == s[-1:] == "$": |
Member
There was a problem hiding this comment.
Any reason not to write if s[0] == s[-1] == "$"
Contributor
Author
There was a problem hiding this comment.
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.
02a0455 to
1c9dbc5
Compare
timhoffm
approved these changes
Oct 9, 2018
jklymak
reviewed
Oct 9, 2018
Member
jklymak
left a comment
There was a problem hiding this comment.
Looks good; needs tests, and an API note I think.
1c9dbc5 to
4dda553
Compare
Contributor
Author
|
added whatsnew (it's not an API change) and test |
Closed
6 tasks
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.
0373d1b to
3b37b08
Compare
Contributor
Author
|
todo: confirm that nothing horrible happens with boundarynorms. |
Contributor
Author
|
Actually one can just try with |
efiring
approved these changes
Dec 10, 2018
6 tasks
6 tasks
This was referenced Aug 23, 2019
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a colorbar exists, use its formatter to format cursor data.
For example, after
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 thoughthe 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