{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Unicode minus\n\nBy default, tick labels at negative values are rendered using a `Unicode\nminus`__ (U+2212) rather than an ASCII hyphen (U+002D). This can be controlled\nby setting :rc:`axes.unicode_minus`.\n\n__ https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes\n\nThe replacement is performed at draw time of the tick labels (usually during a\n`.pyplot.show()` or `.pyplot.savefig()` call). Therefore, all tick labels of\nthe figure follow the same setting and we cannot demonstrate both glyphs on\nreal tick labels of the same figure simultaneously.\n\nInstead, this example simply showcases the difference between the two glyphs\nin a magnified font.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nfig = plt.figure(figsize=(4, 2))\nfig.text(.15, .6, \"Unicode minus:\", fontsize=20)\nfig.text(.85, .6, \"\\N{MINUS SIGN}1\", ha='right', fontsize=20)\nfig.text(.15, .3, \"ASCII hyphen:\", fontsize=20)\nfig.text(.85, .3, \"-1\", ha='right', fontsize=20)\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }