Skip to content

Commit 1610ce5

Browse files
committed
FIX LogFormatterSciNotation now works fine with negative non decade values
1 parent e6512b2 commit 1610ce5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/matplotlib/ticker.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,11 @@ def label_minor(self, labelOnlyBase):
836836
"""
837837
Switch minor tick labeling on or off.
838838
839-
``labelOnlyBase=True`` to turn off minor ticks.
839+
Parameters
840+
----------
841+
labelOnlyBase : bool, optional, default: True
842+
If True, only label decades.
843+
840844
"""
841845
self.labelOnlyBase = labelOnlyBase
842846

@@ -878,7 +882,7 @@ def set_locs(self, locs):
878882

879883
def __call__(self, x, pos=None):
880884
"""
881-
Return the format for tick val `x` at position `pos`.
885+
Return the format for tick val `x`.
882886
"""
883887
b = self._base
884888
if x == 0.0:
@@ -960,8 +964,6 @@ class LogFormatterExponent(LogFormatter):
960964
def __call__(self, x, pos=None):
961965
"""
962966
Return the format for tick value `x`.
963-
964-
The position `pos` is ignored.
965967
"""
966968
vmin, vmax = self.axis.get_view_interval()
967969
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
@@ -1068,11 +1070,11 @@ def _non_decade_format(self, sign_string, base, fx, usetex):
10681070
if is_close_to_int(coeff):
10691071
coeff = nearest_long(coeff)
10701072
if usetex:
1071-
return (r'$%g\times%s^{%d}$') % \
1072-
(coeff, base, exponent)
1073+
return (r'$%s%g\times%s^{%d}$') % \
1074+
(sign_string, coeff, base, exponent)
10731075
else:
1074-
return ('$%s$' % _mathdefault(r'%g\times%s^{%d}' %
1075-
(coeff, base, exponent)))
1076+
return ('$%s$' % _mathdefault(r'%s%g\times%s^{%d}' %
1077+
(sign_string, coeff, base, exponent)))
10761078

10771079

10781080
class LogitFormatter(Formatter):

0 commit comments

Comments
 (0)