From 1bdce560531184ea018991fb01f4ec56ff34995d Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 13 Apr 2019 16:21:33 +0200 Subject: [PATCH] Make unicode_minus example more focused. ... by actually showcasing the difference between unicode minus and ascii hyphen. --- .../unicode_minus.py | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/examples/text_labels_and_annotations/unicode_minus.py b/examples/text_labels_and_annotations/unicode_minus.py index 4acfc07a58fb..892df43bab68 100644 --- a/examples/text_labels_and_annotations/unicode_minus.py +++ b/examples/text_labels_and_annotations/unicode_minus.py @@ -3,25 +3,18 @@ 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. +By default, tick labels at negative values are rendered using a `Unicode +minus`__ (U+2212) rather than an ASCII hyphen (U+002D). This can be controlled +by setting :rc:`axes.unicode_minus` (which defaults to True). __ https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes -The default is to use the Unicode minus. +This example showcases the difference between the two glyphs. """ -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') +fig = plt.figure() +fig.text(.5, .5, "Unicode minus: \N{MINUS SIGN}1", horizontalalignment="right") +fig.text(.5, .4, "ASCII hyphen: -1", horizontalalignment="right") plt.show()