diff --git a/galleries/examples/ticks/ticklabels_rotation.py b/galleries/examples/ticks/ticklabels_rotation.py index 94924d0440f5..5e21b9a352f0 100644 --- a/galleries/examples/ticks/ticklabels_rotation.py +++ b/galleries/examples/ticks/ticklabels_rotation.py @@ -1,9 +1,7 @@ """ -=========================== -Rotating custom tick labels -=========================== - -Demo of custom tick-labels with user-defined rotation. +==================== +Rotating tick labels +==================== """ import matplotlib.pyplot as plt @@ -14,7 +12,22 @@ fig, ax = plt.subplots() ax.plot(x, y) -# You can specify a rotation for the tick labels in degrees or with keywords. +# A tick label rotation can be set using Axes.tick_params. +ax.tick_params("y", rotation=45) +# Alternatively, if setting custom labels with set_xticks/set_yticks, it can +# be set at the same time as the labels. +# For both APIs, the rotation can be an angle in degrees, or one of the strings +# "horizontal" or "vertical". ax.set_xticks(x, labels, rotation='vertical') plt.show() + +# %% +# +# .. admonition:: References +# +# The use of the following functions, methods, classes and modules is shown +# in this example: +# +# - `matplotlib.axes.Axes.tick_params` / `matplotlib.pyplot.tick_params` +# - `matplotlib.axes.Axes.set_xticks` / `matplotlib.pyplot.xticks`