.. note::
    :class: sphx-glr-download-link-note

    Click :ref:`here <sphx_glr_download_gallery_ticks_and_spines_tick_xlabel_top.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_ticks_and_spines_tick_xlabel_top.py:


==========================================
Set default x-axis tick labels on the top
==========================================

We can use :rc:`xtick.labeltop` (default False) and :rc:`xtick.top`
(default False) and :rc:`xtick.labelbottom` (default True) and
:rc:`xtick.bottom` (default True) to control where on the axes ticks and
their labels appear.

These properties can also be set in ``.matplotlib/matplotlibrc``.




.. image:: /gallery/ticks_and_spines/images/sphx_glr_tick_xlabel_top_001.png
    :class: sphx-glr-single-img





.. code-block:: python


    import matplotlib.pyplot as plt
    import numpy as np


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

    x = np.arange(10)

    fig, ax = plt.subplots()

    ax.plot(x)
    ax.set_title('xlabel top')  # Note title moves to make room for ticks

    plt.show()


.. _sphx_glr_download_gallery_ticks_and_spines_tick_xlabel_top.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download

     :download:`Download Python source code: tick_xlabel_top.py <tick_xlabel_top.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: tick_xlabel_top.ipynb <tick_xlabel_top.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
