Skip to content

Avoid plt.xticks/plt.yticks in gallery examples.#28013

Merged
dstansby merged 1 commit intomatplotlib:mainfrom
anntzer:uxt
Apr 3, 2024
Merged

Avoid plt.xticks/plt.yticks in gallery examples.#28013
dstansby merged 1 commit intomatplotlib:mainfrom
anntzer:uxt

Conversation

@anntzer
Copy link
Copy Markdown
Contributor

@anntzer anntzer commented Apr 3, 2024

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

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 dstansby merged commit 3b9b1a2 into matplotlib:main Apr 3, 2024
@anntzer anntzer deleted the uxt branch April 3, 2024 14:47
ax.plot(dates, temperature)
ax.set_ylabel(r'$T\ [^oC]$')
plt.xticks(rotation=70)
ax.xaxis.set_tick_params(rotation=70)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation: examples files in galleries/examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants