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

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

.. _sphx_glr_gallery_text_labels_and_annotations_unicode_minus.py:


=============
Unicode minus
=============

By default, tick labels at negative values are rendered using a `Unicode
minus`__ (U+2212) rather than an ASCII hyphen (U+002D).  This can be controlled
by setting :rc:`axes.unicode_minus`.

__ https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes

The replacement is performed at draw time of the tick labels (usually during a
`.pyplot.show()` or `.pyplot.savefig()` call). Therefore, all tick labels of
the figure follow the same setting and we cannot demonstrate both glyphs on
real tick labels of the same figure simultaneously.

Instead, this example simply showcases the difference between the two glyphs
in a magnified font.




.. image:: /gallery/text_labels_and_annotations/images/sphx_glr_unicode_minus_001.png
    :class: sphx-glr-single-img





.. code-block:: python


    import matplotlib.pyplot as plt

    fig = plt.figure(figsize=(4, 2))
    fig.text(.15, .6, "Unicode minus:", fontsize=20)
    fig.text(.85, .6, "\N{MINUS SIGN}1", ha='right', fontsize=20)
    fig.text(.15, .3, "ASCII hyphen:", fontsize=20)
    fig.text(.85, .3, "-1", ha='right', fontsize=20)
    plt.show()


.. _sphx_glr_download_gallery_text_labels_and_annotations_unicode_minus.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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