Note
Click here to download the full example code
You can use the proper typesetting Unicode minus or the ASCII hyphen for
minus, which some people prefer. rcParams["axes.unicode_minus"] = True
controls the default
behavior.
The default is to use the Unicode minus.
Traceback (most recent call last):
File "/build/matplotlib-xz4j8t/matplotlib-3.1.2/examples/text_labels_and_annotations/unicode_minus.py", line 1
=============
^
SyntaxError: invalid syntax
=============
Unicode minus
=============
You can use the proper typesetting `Unicode minus`__ or the ASCII hyphen for
minus, which some people prefer. :rc:`axes.unicode_minus` controls the default
behavior.
__ https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes
The default is to use the Unicode minus.
"""
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
# Fixing random state for reproducibility
np.random.seed(19680801)
matplotlib.rcParams['axes.unicode_minus'] = False
fig, ax = plt.subplots()
ax.plot(10*np.random.randn(100), 10*np.random.randn(100), 'o')
ax.set_title('Using hyphen instead of Unicode minus')
plt.show()
Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery