-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC: Modernize Colorbar Tick Labelling example #26255
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
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.
The must change or address are the comments having to do w/ our doc conventions, the rest are copy edits.
Vertical colorbars have their y axis labelled, horizontal ones their x axis. | ||
The ``ticks`` and ``format`` parameters can be used to set ticks and format | ||
labels of these axes. For further adjustments, the ``yaxis`` or ``xaxis`` axes | ||
of the colorbar can be retrieved using its ``ax`` property. |
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.
Vertical colorbars have their y axis labelled, horizontal ones their x axis. | |
The ``ticks`` and ``format`` parameters can be used to set ticks and format | |
labels of these axes. For further adjustments, the ``yaxis`` or ``xaxis`` axes | |
of the colorbar can be retrieved using its ``ax`` property. | |
Vertical colorbars have ticks, tick labels, and labels visible on the *y* axis, horizontal colorbars on the *x* axis. The ``ticks`` parameter can be used to set the ticks and the ``format`` parameter can be used to format the tick labels of the colorbar axes. For further adjustments, the ``yaxis`` or ``xaxis`` axes of the colorbar can be retrieved using its ``ax`` property. |
Tried to make everything a little more explicit and unpacked.
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, much better now. I just inserted the word visible
in
... can be used to format the tick labels of the visible colorbar axes.
to underline that you can use these parameters no matter what the colorbar orientation is, there is no need to resort to the specific x/y axis functions
- use colorbar.set_ticks instead of colorbar.ax.set_[x|y]ticklabels whose usage is discouraged - now that we don't have to handle vertical and horizontal colorbars differently we can instead show different ways to achieve the same and show additional tweaks like labelling the colorbar extensions (strictly speaking the old labels >1 and <-1 were simply wrong for clipped data) - update numpy random number generation - add admonition
ae9f762
to
1542cee
Compare
@story645 Thanks for the review. All done. The only annoying thing is that the isort commit hook insists in changing
into
(see also https://discourse.matplotlib.org/t/isort-run-as-commit-hook/23932) Is this a bug in isort or am I missing something here? |
I think this was a deliberate choice for the examples when we added the isort hook, see #25099 (comment). |
|
||
# Fixing random state for reproducibility | ||
np.random.seed(19680801) | ||
rng = np.random.default_rng(seed=19680801) | ||
|
||
# %% | ||
# Make plot with vertical (default) colorbar |
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.
Final little nit that can also happen in follow up - how do you feel about making this and the horizontal note instead be subsection titles?
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.
I'd rather not make them be subsection titles as both vertical and horizontal colorbars work exactly the same way. Subsections would be appropriate if we had different cases to contrast, in my opinion.
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.
I hear you, what I'm thinking of is that in the sidebar you can scan quickly to click to find your case. Also maybe that if what you want to highlight is that they're exactly the same, then I'd maybe do this as a side by side subplot so that I could stack the identical code next to each other...either way I'll merge this and push that off.
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
PR summary
The clause "Contributed by Scott Sinclair" was removed in the process as I think contributors can be looked up in git but I can of course add this phrase back if desired.
PR checklist