.. 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 ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_ticks_ticklabels_rotation.py: =========================== Rotating custom tick labels =========================== Demo of custom tick-labels with user-defined rotation. .. GENERATED FROM PYTHON SOURCE LINES 8-22 .. 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 .. 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) # 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_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 ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ticklabels_rotation.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_