Avoid plt.xticks/plt.yticks in gallery examples.#28013
Merged
dstansby merged 1 commit intomatplotlib:mainfrom Apr 3, 2024
Merged
Avoid plt.xticks/plt.yticks in gallery examples.#28013dstansby merged 1 commit intomatplotlib:mainfrom
dstansby merged 1 commit intomatplotlib:mainfrom
Conversation
In particular, the ticklabels_rotation example is likely the one most easily found by those looking for how to do this; let's not suggest that plt.xticks is "the" way to rotate ticklabels. Also remove the margins() call (which was really only needed with the old round_numbers autolimits mode) and the subplots_adjust() call (the ticklabels already fit in, and the modern approach would be to use constrained_layout anyways).
dstansby
approved these changes
Apr 3, 2024
timhoffm
reviewed
Apr 3, 2024
| ax.plot(dates, temperature) | ||
| ax.set_ylabel(r'$T\ [^oC]$') | ||
| plt.xticks(rotation=70) | ||
| ax.xaxis.set_tick_params(rotation=70) |
Member
There was a problem hiding this comment.
I'm always unsure whether to go through xaxis or ax.tick_params('x', rotation=70). Slight tendency for the higher-level ax.tick_params in simple cases but basically either is fine.
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.
In particular, the ticklabels_rotation example is likely the one most easily found by those looking for how to do this; let's not suggest that plt.xticks is "the" way to rotate ticklabels.
Also remove the margins() call (which was really only needed with the old round_numbers autolimits mode) and the subplots_adjust() call (the ticklabels already fit in, and the modern approach would be to use constrained_layout anyways).
PR summary
PR checklist