-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix: bottom and left text appearance in colorbar #25438
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
Conversation
It is a bit hard to say what it actually should do as there is no doc-string, but I am not sure this is the right fix.
- Passing
toggle_label(True)
should switch them back on. - This only covers half of the possible cases.
(It is a bit strange that orientation
is actually what one would think is location
.)
I think a better solution is to make a dict that picks the "opposite" axis name and then uses that. (If that is now the solution.)
Looking at https://matplotlib.org/3.3.4/gallery/axes_grid1/demo_axes_grid.html#sphx-glr-gallery-axes-grid1-demo-axes-grid-py (which probably shows the "correct" behaviour), it seems that maybe the solution is to put the ticks and the labels on the top when "orientation" is "top" etc. In this way toggle_label
will work as expected.
edit: Should the colorbar show ticks when
set_labels
is set toFalse
. It is visible in this example, But this PR currently removes the ticks as well isset_labels
is False.
If there are no tick labels, ticks don't have a meaning. So, whether or not to remove them is a purely aesthetic decision. IMHO it's fine to remove them.
If there are no tick labels, ticks don't have a meaning. So, whether or not to remove them is a purely aesthetic decision. IMHO it's fine to remove them.
Thanks for confirming @timhoffm, Is there any additional changes needed?
Gentle ping @oscargus - would you mind taking a look again?
Hi @xtanion, thank you for your work on this and sorry it has taken a while to get back to you.
It’s great that you have confirmed locally that the method now has the correct behaviour. Could you simplify the code you checked with and make it an image comparison test? Simplify because it just needs enough to prove the desired behaviour is happening with the ticks (so e.g. no need for the annotations).
The documentation build check has failed due to a problem that I think has been fixed on main
. So could you also rebase your branch to pick up that fix? That would allow us to see how your change affects the original example from the issue.
Will that work if the colorbars are on the bottom or the left side? I'm not so sure...
Edit: I think this is not the right approach at all, see #25884 instead.
Superseded by #25884. Thanks for the PR!
Uh oh!
There was an error while loading. Please reload this page.
PR Summary
This PR fixes
CbarAxes.toggle_label
inconsistency as mentioned in issue #23595closes #23595
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst