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

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

.. _sphx_glr_gallery_text_labels_and_annotations_usetex_baseline_test.py:


====================
Usetex text baseline
====================

Comparison of text baselines computed for mathtext and usetex.

.. GENERATED FROM PYTHON SOURCE LINES 8-26



.. image-sg:: /gallery/text_labels_and_annotations/images/sphx_glr_usetex_baseline_test_001.png
   :alt: usetex=False , usetex=True 
   :srcset: /gallery/text_labels_and_annotations/images/sphx_glr_usetex_baseline_test_001.png, /gallery/text_labels_and_annotations/images/sphx_glr_usetex_baseline_test_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt

    plt.rcParams.update({"mathtext.fontset": "cm", "mathtext.rm": "serif"})
    axs = plt.figure(figsize=(2 * 3, 6.5)).subplots(1, 2)
    for ax, usetex in zip(axs, [False, True]):
        ax.axvline(0, color="r")
        test_strings = ["lg", r"$\frac{1}{2}\pi$", r"$p^{3^A}$", r"$p_{3_2}$"]
        for i, s in enumerate(test_strings):
            ax.axhline(i, color="r")
            ax.text(0., 3 - i, s,
                    usetex=usetex,
                    verticalalignment="baseline",
                    size=50,
                    bbox=dict(pad=0, ec="k", fc="none"))
        ax.set(xlim=(-0.1, 1.1), ylim=(-.8, 3.9), xticks=[], yticks=[],
               title=f"usetex={usetex}\n")
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.432 seconds)


.. _sphx_glr_download_gallery_text_labels_and_annotations_usetex_baseline_test.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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