10000 Make unicode_minus example more focused. · matplotlib/matplotlib@37fe9cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 37fe9cd

Browse files
committed
Make unicode_minus example more focused.
... by actually showcasing the difference between unicode minus and ascii hyphen.
1 parent dd18211 commit 37fe9cd

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

examples/text_labels_and_annotations/unicode_minus.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,16 @@
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) rathen than an ASCII hyphen (U+002D). This can be controlled
8+
by setting :rc:`axes.unicode_minus` (which defaults to True).
99
10-
__ https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes
11-
12-
The default is to use the Unicode minus.
10+
This example showcases the difference between the two glyphs.
1311
"""
1412

15-
import numpy as np
16-
import matplotlib
1713
import matplotlib.pyplot as plt
1814

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')
15+
fig = plt.figure()
16+
fig.text(.5, .5, "Unicode minus: \N{MINUS SIGN}1", horizontalalignment="right")
17+
fig.text(.5, .4, "ASCII hyphen: -1", horizontalalignment="right")
2718
plt.show()

0 commit comments

Comments
 (0)
0