Skip to content

Commit e2de966

Browse files
committed
Merge pull request #7337 from NelleV/7211_symlog
FIX symlog scale now shows negative labels. Conflicts: lib/matplotlib/tests/test_ticker.py
1 parent 92da7f6 commit e2de966

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/matplotlib/tests/test_ticker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
import six
54
import nose.tools
65
from nose.tools import assert_equal, assert_raises
76
from numpy.testing import assert_almost_equal
@@ -312,6 +311,7 @@ def get_view_interval(self):
312311
def test_LogFormatterSciNotation():
313312
test_cases = {
314313
10: (
314+
(-1, '${-10^{0}}$'),
315315
(1e-05, '${10^{-5}}$'),
316316
(1, '${10^{0}}$'),
317317
(100000, '${10^{5}}$'),

lib/matplotlib/ticker.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -869,14 +869,15 @@ def __call__(self, x, pos=None):
869869
if x == 0.0:
870870
return '0'
871871
sign = np.sign(x)
872+
x = abs(x)
872873
# only label the decades
873-
fx = math.log(abs(x)) / math.log(b)
874+
fx = math.log(x) / math.log(b)
874875
isDecade = is_close_to_int(fx)
875876
exponent = np.round(fx) if isDecade else np.floor(fx)
876877
coeff = np.round(x / b ** exponent)
877878
if coeff in self.sublabel:
878879
if not isDecade and self.labelOnlyBase:
879-
s = ''
880+
return ''
880881
elif x > 10000:
881882
s = '%1.0e' % x
882883
elif x < 1:
@@ -1003,7 +1004,7 @@ def __call__(self, x, pos=None):
10031004
fx = math.log(abs(x)) / math.log(b)
10041005
is_decade = is_close_to_int(fx)
10051006
exponent = np.round(fx) if is_decade else np.floor(fx)
1006-
coeff = np.round(x / b ** exponent)
1007+
coeff = np.round(abs(x) / b ** exponent)
10071008

10081009
sign_string = '-' if x < 0 else ''
10091010

0 commit comments

Comments
 (0)