
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/axisartist/demo_ticklabel_alignment.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_axisartist_demo_ticklabel_alignment.py>`
        to download the full example code.

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

.. _sphx_glr_gallery_axisartist_demo_ticklabel_alignment.py:


===================
Ticklabel alignment
===================

.. GENERATED FROM PYTHON SOURCE LINES 7-41



.. image-sg:: /gallery/axisartist/images/sphx_glr_demo_ticklabel_alignment_001.png
   :alt: demo ticklabel alignment
   :srcset: /gallery/axisartist/images/sphx_glr_demo_ticklabel_alignment_001.png, /gallery/axisartist/images/sphx_glr_demo_ticklabel_alignment_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python



    import matplotlib.pyplot as plt

    import mpl_toolkits.axisartist as axisartist


    def setup_axes(fig, pos):
        ax = fig.add_subplot(pos, axes_class=axisartist.Axes)
        ax.set_yticks([0.2, 0.8], labels=["short", "loooong"])
        ax.set_xticks([0.2, 0.8], labels=[r"$\frac{1}{2}\pi$", r"$\pi$"])
        return ax


    fig = plt.figure(figsize=(3, 5))
    fig.subplots_adjust(left=0.5, hspace=0.7)

    ax = setup_axes(fig, 311)
    ax.set_ylabel("ha=right")
    ax.set_xlabel("va=baseline")

    ax = setup_axes(fig, 312)
    ax.axis["left"].major_ticklabels.set_ha("center")
    ax.axis["bottom"].major_ticklabels.set_va("top")
    ax.set_ylabel("ha=center")
    ax.set_xlabel("va=top")

    ax = setup_axes(fig, 313)
    ax.axis["left"].major_ticklabels.set_ha("left")
    ax.axis["bottom"].major_ticklabels.set_va("bottom")
    ax.set_ylabel("ha=left")
    ax.set_xlabel("va=bottom")

    plt.show()


.. _sphx_glr_download_gallery_axisartist_demo_ticklabel_alignment.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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