Skip to content

Commit 643df71

Browse files
authored
Merge pull request #28455 from anntzer/tre
Expand ticklabels_rotation example to cover rotating default ticklabels.
2 parents d7d1bba + 6578b64 commit 643df71

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""
2-
===========================
3-
Rotating custom tick labels
4-
===========================
5-
6-
Demo of custom tick-labels with user-defined rotation.
2+
====================
3+
Rotating tick labels
4+
====================
75
"""
86

97
import matplotlib.pyplot as plt
@@ -14,7 +12,22 @@
1412

1513
fig, ax = plt.subplots()
1614
ax.plot(x, y)
17-
# You can specify a rotation for the tick labels in degrees or with keywords.
15+
# A tick label rotation can be set using Axes.tick_params.
16+
ax.tick_params("y", rotation=45)
17+
# Alternatively, if setting custom labels with set_xticks/set_yticks, it can
18+
# be set at the same time as the labels.
19+
# For both APIs, the rotation can be an angle in degrees, or one of the strings
20+
# "horizontal" or "vertical".
1821
ax.set_xticks(x, labels, rotation='vertical')
1922

2023
plt.show()
24+
25+
# %%
26+
#
27+
# .. admonition:: References
28+
#
29+
# The use of the following functions, methods, classes and modules is shown
30+
# in this example:
31+
#
32+
# - `matplotlib.axes.Axes.tick_params` / `matplotlib.pyplot.tick_params`
33+
# - `matplotlib.axes.Axes.set_xticks` / `matplotlib.pyplot.xticks`

0 commit comments

Comments
 (0)