Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a55cd9

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

File tree

Expand file treeCollapse file tree

1 file changed

+7
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-14
lines changed

‎examples/text_labels_and_annotations/unicode_minus.py

Copy file name to clipboardExpand all lines: examples/text_labels_and_annotations/unicode_minus.py
+7-14Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.