File tree 1 file changed +19
-6
lines changed
1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
- ===========================
3
- Rotating custom tick labels
4
- ===========================
5
-
6
- Demo of custom tick-labels with user-defined rotation.
2
+ ====================
3
+ Rotating tick labels
4
+ ====================
7
5
"""
8
6
9
7
import matplotlib .pyplot as plt
14
12
15
13
fig , ax = plt .subplots ()
16
14
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".
18
21
ax .set_xticks (x , labels , rotation = 'vertical' )
19
22
20
23
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`
You can’t perform that action at this time.
0 commit comments