-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathtick_xlabel_top.py
More file actions
32 lines (23 loc) · 906 Bytes
/
tick_xlabel_top.py
File metadata and controls
32 lines (23 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
==================================
Move x-axis tick labels to the top
==================================
`~.axes.Axes.tick_params` can be used to configure the ticks. *top* and
*labeltop* control the visibility tick lines and labels at the top x-axis.
To move x-axis ticks from bottom to top, we have to activate the top ticks
and deactivate the bottom ticks::
ax.tick_params(top=True, labeltop=True, bottom=False, labelbottom=False)
.. note::
If the change should be made for all future plots and not only the current
Axes, you can adapt the respective config parameters
- :rc:`xtick.top`
- :rc:`xtick.labeltop`
- :rc:`xtick.bottom`
- :rc:`xtick.labelbottom`
"""
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(range(10))
ax.tick_params(top=True, labeltop=True, bottom=False, labelbottom=False)
ax.set_title('x-ticks moved to the top')
plt.show()