-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: colorbars with NoNorm #21872
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: colorbars with NoNorm #21872
Conversation
Side tangent about svg: it may be worth switching at least some of the svg baseline outputs to use svg.fonttype = None which simply embeds text as text, gaining a lot on the svg sizes. |
fig.savefig('/tmp/wat.svg') | ||
fig.savefig('/tmp/wat.png') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fig.savefig('/tmp/wat.svg') | |
fig.savefig('/tmp/wat.png') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦🏻 At least some of my even more frustrated debugging statements did not make it in!
lib/matplotlib/colorbar.py
Outdated
@@ -839,7 +839,7 @@ def _get_ticker_locator_formatter(self): | |||
# default locator: | |||
nv = len(self._values) | |||
base = 1 + int(nv / 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be moved up a level in the elif after BoundaryNorm
? It seems out of place here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few suggestions.
Part of my problem with these changes is that they were not exercised with tests and they did not have any comments, so it was pretty hard to know to check the specific cases. I think adding more comments in here will help in the future.
I'd need to think if there is more we can do on the Norm itself to inform the colorbar of how to set locators and ticks. I think we do that now with scales on the norm, so maybe BoundaryNorm and NoNorm can get scales.
Closes matplotlib#21870 This adds another special-case path for NoNorm and tweaks the contents of another. These special-cases are required because NoNorm (like BoundaryNorm) has a different return value than ever other Norm (it directly returns integers to index into the LUT rather than [0, 1] that is later mapped into the LUT. Co-authored-by: Jody Klymak <[email protected]>
I agree, but not as a 3.5.1 patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for chasing this down and fixing it, and apologies for breaking it in the first place!
…872-on-v3.5.x Backport PR #21872 on branch v3.5.x (FIX: colorbars with NoNorm)
Closes #21870
This adds another special-case path for NoNorm and tweaks the contents of another.
These special-cases are required because NoNorm (like BoundaryNorm) has a
different return value than ever other Norm (it directly returns integers to
index into the LUT rather than [0, 1] that is later mapped into the LUT.
PR Summary
I added this as an SVG because getting the text right is a critical part of this and SVG will not suffer from our free-type issues.
(I went through a minor panic when I was not seeing ticklabels in the svg, but luckily that was a viewer (emacs) bug 😌 but I did have 15 minutes of thinking we had stopped outputting any text on SVGs! This may be (another) rsvg bug....)
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).