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

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

.. _sphx_glr_gallery_ticks_and_spines_ticklabels_rotation.py:


===========================
Rotating custom tick labels
===========================

Demo of custom tick-labels with user-defined rotation.




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





.. code-block:: python

    import matplotlib.pyplot as plt


    x = [1, 2, 3, 4]
    y = [1, 4, 9, 6]
    labels = ['Frogs', 'Hogs', 'Bogs', 'Slogs']

    plt.plot(x, y, 'ro')
    # You can specify a rotation for the tick labels in degrees or with keywords.
    plt.xticks(x, labels, rotation='vertical')
    # Pad margins so that markers don't get clipped by the axes
    plt.margins(0.2)
    # Tweak spacing to prevent clipping of tick-labels
    plt.subplots_adjust(bottom=0.15)
    plt.show()


.. _sphx_glr_download_gallery_ticks_and_spines_ticklabels_rotation.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: ticklabels_rotation.ipynb <ticklabels_rotation.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>`_
