X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 32 additions & 24 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2465,30 +2465,32 @@ def ticklabel_format(self, **kwargs):

Optional keyword arguments:

============ =========================================
Keyword Description
============ =========================================
*style* [ 'sci' (or 'scientific') | 'plain' ]
plain turns off scientific notation
*scilimits* (m, n), pair of integers; if *style*
is 'sci', scientific notation will
be used for numbers outside the range
10`m`:sup: to 10`n`:sup:.
Use (0,0) to include all numbers.
*useOffset* [True | False | offset]; if True,
the offset will be calculated as needed;
if False, no offset will be used; if a
numeric offset is specified, it will be
used.
*axis* [ 'x' | 'y' | 'both' ]
*useLocale* If True, format the number according to
the current locale. This affects things
such as the character used for the
decimal separator. If False, use
C-style (English) formatting. The
default setting is controlled by the
axes.formatter.use_locale rcparam.
============ =========================================
============== =========================================
Keyword Description
============== =========================================
*style* [ 'sci' (or 'scientific') | 'plain' ]
plain turns off scientific notation
*scilimits* (m, n), pair of integers; if *style*
is 'sci', scientific notation will
be used for numbers outside the range
10`m`:sup: to 10`n`:sup:.
Use (0,0) to include all numbers.
*useOffset* [True | False | offset]; if True,
the offset will be calculated as needed;
if False, no offset will be used; if a
numeric offset is specified, it will be
used.
*axis* [ 'x' | 'y' | 'both' ]
*useLocale* If True, format the number according to
the current locale. This affects things
such as the character used for the
decimal separator. If False, use
C-style (English) formatting. The
default setting is controlled by the
axes.formatter.use_locale rcparam.
*useMathText* If True, render the offset and scientific
notation in mathtext
============== =========================================

Only the major ticks are affected.
If the method is called when the
Expand All @@ -2501,6 +2503,7 @@ def ticklabel_format(self, **kwargs):
scilimits = kwargs.pop('scilimits', None)
useOffset = kwargs.pop('useOffset', None)
useLocale = kwargs.pop('useLocale', None)
useMathText = kwargs.pop('useMathText', None)
axis = kwargs.pop('axis', 'both').lower()
if scilimits is not None:
try:
Expand Down Expand Up @@ -2542,6 +2545,11 @@ def ticklabel_format(self, **kwargs):
self.xaxis.major.formatter.set_useLocale(useLocale)
if axis == 'both' or axis == 'y':
self.yaxis.major.formatter.set_useLocale(useLocale)
if useMathText is not None:
if axis == 'both' or axis == 'x':
self.xaxis.major.formatter.set_useMathText(useMathText)
if axis == 'both' or axis == 'y':
self.yaxis.major.formatter.set_useMathText(useMathText)
except AttributeError:
raise AttributeError(
"This method only works with the ScalarFormatter.")
Expand Down
13 changes: 12 additions & 1 deletion lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def __init__(self, useOffset=None, useMathText=None, useLocale=None):
self._usetex = rcParams['text.usetex']
if useMathText is None:
useMathText = rcParams['axes.formatter.use_mathtext']
self._useMathText = useMathText
self.set_useMathText(useMathText)
self.orderOfMagnitude = 0
self.format = ''
self._scientific = True
Expand Down Expand Up @@ -485,6 +485,17 @@ def set_useLocale(self, val):

useLocale = property(fget=get_useLocale, fset=set_useLocale)

def get_useMathText(self):
return self._useMathText

def set_useMathText(self, val):
if val is None:
self._useMathText = rcParams['axes.formatter.use_mathtext']
else:
self._useMathText = val

useMathText = property(fget=get_useMathText, fset=set_useMathText)

def fix_minus(self, s):
"""use a unicode minus rather than hyphen"""
if rcParams['text.usetex'] or not rcParams['axes.unicode_minus']:
Expand Down
X Tutup