
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/ticks/ticklabels_rotation.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

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

        :ref:`Go to the end <sphx_glr_download_gallery_ticks_ticklabels_rotation.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_ticks_ticklabels_rotation.py:


===================
Rotated tick labels
===================

.. GENERATED FROM PYTHON SOURCE LINES 6-25

.. code-block:: Python


    import matplotlib.pyplot as plt

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

    fig, ax = plt.subplots()
    ax.plot(x, y)
    # A tick label rotation can be set using Axes.tick_params.
    ax.tick_params("y", rotation=45)
    # Alternatively, if setting custom labels with set_xticks/set_yticks, it can
    # be set at the same time as the labels.
    # For both APIs, the rotation can be an angle in degrees, or one of the strings
    # "horizontal" or "vertical".
    ax.set_xticks(x, labels, rotation='vertical')

    plt.show()




.. image-sg:: /gallery/ticks/images/sphx_glr_ticklabels_rotation_001.png
   :alt: ticklabels rotation
   :srcset: /gallery/ticks/images/sphx_glr_ticklabels_rotation_001.png, /gallery/ticks/images/sphx_glr_ticklabels_rotation_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 26-33

.. admonition:: References

   The use of the following functions, methods, classes and modules is shown
   in this example:

   - `matplotlib.axes.Axes.tick_params` / `matplotlib.pyplot.tick_params`
   - `matplotlib.axes.Axes.set_xticks` / `matplotlib.pyplot.xticks`


.. _sphx_glr_download_gallery_ticks_ticklabels_rotation.py:

.. only:: html

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

    .. container:: sphx-glr-download sphx-glr-download-jupyter

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

    .. container:: sphx-glr-download sphx-glr-download-python

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

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: ticklabels_rotation.zip <ticklabels_rotation.zip>`


.. only:: html

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

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
