You are reading an old version of the documentation (v2.2.2). For the latest version see
Version 2.2.2
Fork me on GitHub

Related Topics

Set default x-axis tick labels on the topΒΆ

We can use rcParams["xtick.labeltop"] (default False) and rcParams[""] (default False) and rcParams["xtick.labelbottom"] (default True) and rcParams["xtick.bottom"] (default True) to control where on the axes ticks and their labels appear. These properties can also be set in the .matplotlib/matplotlibrc.

import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['xtick.bottom'] = plt.rcParams['xtick.labelbottom'] = False
plt.rcParams[''] = plt.rcParams['xtick.labeltop'] = True

x = np.arange(10)

fig, ax = plt.subplots()

ax.set_title('xlabel top', pad=24)  # increase padding to make room for labels

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery