.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/ticks/tick_xlabel_top.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_ticks_tick_xlabel_top.py: ================================== 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` .. GENERATED FROM PYTHON SOURCE LINES 24-33 .. image-sg:: /gallery/ticks/images/sphx_glr_tick_xlabel_top_001.png :alt: x-ticks moved to the top :srcset: /gallery/ticks/images/sphx_glr_tick_xlabel_top_001.png, /gallery/ticks/images/sphx_glr_tick_xlabel_top_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python 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() .. _sphx_glr_download_gallery_ticks_tick_xlabel_top.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: tick_xlabel_top.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: tick_xlabel_top.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_