Skip to content

Commit 6a55cd9

Browse files
authored
Merge pull request #13945 from anntzer/unicodeminus
Make unicode_minus example more focused.
2 parents 11120f3 + 1bdce56 commit 6a55cd9

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

examples/text_labels_and_annotations/unicode_minus.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,18 @@
33
Unicode minus
44
=============
55
6-
You can use the proper typesetting `Unicode minus`__ or the ASCII hyphen for
7-
minus, which some people prefer. :rc:`axes.unicode_minus` controls the default
8-
behavior.
6+
By default, tick labels at negative values are rendered using a `Unicode
7+
minus`__ (U+2212) rather than an ASCII hyphen (U+002D). This can be controlled
8+
by setting :rc:`axes.unicode_minus` (which defaults to True).
99
1010
__ https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes
1111
12-
The default is to use the Unicode minus.
12+
This example showcases the difference between the two glyphs.
1313
"""
1414

15-
import numpy as np
16-
import matplotlib
1715
import matplotlib.pyplot as plt
1816

19-
# Fixing random state for reproducibility
20-
np.random.seed(19680801)
21-
22-
23-
matplotlib.rcParams['axes.unicode_minus'] = False
24-
fig, ax = plt.subplots()
25-
ax.plot(10*np.random.randn(100), 10*np.random.randn(100), 'o')
26-
ax.set_title('Using hyphen instead of Unicode minus')
17+
fig = plt.figure()
18+
fig.text(.5, .5, "Unicode minus: \N{MINUS SIGN}1", horizontalalignment="right")
19+
fig.text(.5, .4, "ASCII hyphen: -1", horizontalalignment="right")
2720
plt.show()

0 commit comments

Comments
 (0)