From: <jd...@us...> - 2008-11-25 22:22:52
|
Revision: 6453 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6453&view=rev Author: jdh2358 Date: 2008-11-25 21:43:36 +0000 (Tue, 25 Nov 2008) Log Message: ----------- added rc param axes.unicode_minus Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/projections/polar.py trunk/matplotlib/lib/matplotlib/rcsetup.py trunk/matplotlib/lib/matplotlib/ticker.py trunk/matplotlib/matplotlibrc.template Added Paths: ----------- trunk/matplotlib/examples/api/unicode_minus.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-11-25 21:14:13 UTC (rev 6452) +++ trunk/matplotlib/CHANGELOG 2008-11-25 21:43:36 UTC (rev 6453) @@ -1,3 +1,6 @@ +2008-11-25 Added rcParam axes.unicode_minus which allows plain hypen + for minus when False - JDH + 2008-11-25 Added scatterpoints support in Legend. patch by Erik Tollerud - JJL Added: trunk/matplotlib/examples/api/unicode_minus.py =================================================================== --- trunk/matplotlib/examples/api/unicode_minus.py (rev 0) +++ trunk/matplotlib/examples/api/unicode_minus.py 2008-11-25 21:43:36 UTC (rev 6453) @@ -0,0 +1,18 @@ +""" +You can use the proper typesetting unicode minus (see +http://en.wikipedia.org/wiki/Plus_sign#Plus_sign) or the ASCII hypen +for minus, which some people prefer. The matplotlibrc param +axes.unicode_minus controls the default behavior. + +The default is to use the unicode minus +""" +import numpy as np +import matplotlib +import matplotlib.pyplot as plt + +matplotlib.rcParams['axes.unicode_minus'] = False +fig = plt.figure() +ax = fig.add_subplot(111) +ax.plot(10*np.random.randn(100), 10*np.random.randn(100), 'o') +ax.set_title('Using hypen instead of unicode minus') +plt.show() Modified: trunk/matplotlib/lib/matplotlib/projections/polar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/projections/polar.py 2008-11-25 21:14:13 UTC (rev 6452) +++ trunk/matplotlib/lib/matplotlib/projections/polar.py 2008-11-25 21:43:36 UTC (rev 6453) @@ -139,6 +139,11 @@ if rcParams['text.usetex'] and not rcParams['text.latex.unicode']: return r"$%d^\circ$" % ((x / npy.pi) * 180.0) else: + # we use unicode, rather than mathtext with \circ, so + # that it will work correctly with any arbitrary font + # (assuming it has a degree sign), whereas $5\circ$ + # will only work correctly with one of the supported + # math fonts (Computer Modern and STIX) return u"%d\u00b0" % ((x / npy.pi) * 180.0) class RadialLocator(Locator): Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-11-25 21:14:13 UTC (rev 6452) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-11-25 21:43:36 UTC (rev 6453) @@ -412,6 +412,7 @@ # use scientific notation if log10 # of the axis range is smaller than the # first or larger than the second + 'axes.unicode_minus' : [True, validate_bool], 'polaraxes.grid' : [True, validate_bool], # display polar grid or not Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2008-11-25 21:14:13 UTC (rev 6452) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2008-11-25 21:43:36 UTC (rev 6453) @@ -313,7 +313,7 @@ def fix_minus(self, s): 'use a unicode minus rather than hyphen' - if rcParams['text.usetex']: return s + if rcParams['text.usetex'] or not rcParams['axes.unicode_minus']: return s else: return s.replace('-', u'\u2212') def __call__(self, x, pos=None): Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008-11-25 21:14:13 UTC (rev 6452) +++ trunk/matplotlib/matplotlibrc.template 2008-11-25 21:43:36 UTC (rev 6453) @@ -205,6 +205,8 @@ #axes.formatter.limits : -7, 7 # use scientific notation if log10 # of the axis range is smaller than the # first or larger than the second +#axes.unicode_minus : True # use unicode for the minus symbol + # rather than hypen. See http://en.wikipedia.org/wiki/Plus_sign#Plus_sign #polaraxes.grid : True # display grid on polar axes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |