Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93abf33

Browse files
committed
make ScalarFormatter use of mathtext configurable
1 parent 95a0f36 commit 93abf33

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2011-12-01 Make use of mathtext in tick labels configurable - DSD
2+
13
2011-10-25 added support for \operatorname to mathtext,
24
including the ability to insert spaces, such as
35
$\operatorname{arg\,max}$ - PI

lib/matplotlib/rcsetup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,9 @@ def __call__(self, s):
450450
# use scientific notation if log10
451451
# of the axis range is smaller than the
452452
# first or larger than the second
453-
'axes.formatter.use_locale' : [False, validate_bool], # Use the current locale to format ticks
453+
'axes.formatter.use_locale' : [False, validate_bool],
454+
# Use the current locale to format ticks
455+
'axes.formatter.use_mathtext' : [False, validate_bool],
454456
'axes.unicode_minus' : [True, validate_bool],
455457
'axes.color_cycle' : [['b','g','r','c','m','y','k'],
456458
validate_colorlist], # cycle of plot

lib/matplotlib/ticker.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,21 +330,22 @@ class ScalarFormatter(Formatter):
330330
331331
"""
332332

333-
def __init__(self, useOffset=True, useMathText=False, useLocale=None):
333+
def __init__(self, useOffset=True, useMathText=None, useLocale=None):
334334
# useOffset allows plotting small data ranges with large offsets:
335335
# for example: [1+1e-9,1+2e-9,1+3e-9]
336336
# useMathText will render the offset and scientific notation in mathtext
337337
self.set_useOffset(useOffset)
338338
self._usetex = rcParams['text.usetex']
339+
if useMathText is None:
340+
useMathText = rcParams['axes.formatter.use_mathtext']
339341
self._useMathText = useMathText
340342
self.orderOfMagnitude = 0
341343
self.format = ''
342344
self._scientific = True
343345
self._powerlimits = rcParams['axes.formatter.limits']
344346
if useLocale is None:
345-
self._useLocale = rcParams['axes.formatter.use_locale']
346-
else:
347-
self._useLocale = useLocale
347+
useLocale = rcParams['axes.formatter.use_locale']
348+
self._useLocale = useLocale
348349

349350
def get_useOffset(self):
350351
return self._useOffset

matplotlibrc.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ backend : %(backend)s
216216
# according to the user's locale.
217217
# For example, use ',' as a decimal
218218
# separator in the fr_FR locale.
219+
#axes.formatter.use_mathtext : False # When True, use mathtext for scientific
220+
# notation.
219221
#axes.unicode_minus : True # use unicode for the minus symbol
220222
# rather than hypen. See
221223
# http://en.wikipedia.org/wiki/Plus_sign

0 commit comments

Comments
 (0)