Note
Go to the endto download the full example code.
Move x-axis tick labels to the top#
tick_params can be used to configure the ticks.top andlabeltop 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 ticksand 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 currentAxes, you can adapt the respective config parameters
rcParams["xtick.top"](default:False)rcParams["xtick.labeltop"](default:False)rcParams["xtick.bottom"](default:True)rcParams["xtick.labelbottom"](default:True)

importmatplotlib.pyplotaspltfig,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()