Skip to content

Commit d52675f

Browse files
committed
FIX symlog scale now shows negative labels.
The formatter returned empty strings for negative value. closes #7146
1 parent 23afcb4 commit d52675f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/matplotlib/tests/test_ticker.py

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

4-
import six
5-
64
from numpy.testing import assert_almost_equal
75
import numpy as np
86
import pytest
@@ -305,6 +303,7 @@ def test_LogFormatterExponent_blank():
305303
def test_LogFormatterSciNotation():
306304
test_cases = {
307305
10: (
306+
(-1, '${-10^{0}}$'),
308307
(1e-05, '${10^{-5}}$'),
309308
(1, '${10^{0}}$'),
310309
(100000, '${10^{5}}$'),

lib/matplotlib/ticker.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ def __call__(self, x, pos=None):
902902
fx = math.log(abs(x)) / math.log(b)
903903
isDecade = is_close_to_int(fx)
904904
exponent = np.round(fx) if isDecade else np.floor(fx)
905-
coeff = np.round(x / b ** exponent)
905+
coeff = np.round(abs(x) / b ** exponent)
906906
if coeff in self.sublabel:
907907
if not isDecade and self.labelOnlyBase:
908908
s = ''
@@ -1032,7 +1032,7 @@ def __call__(self, x, pos=None):
10321032
fx = math.log(abs(x)) / math.log(b)
10331033
is_decade = is_close_to_int(fx)
10341034
exponent = np.round(fx) if is_decade else np.floor(fx)
1035-
coeff = np.round(x / b ** exponent)
1035+
coeff = np.round(abs(x) / b ** exponent)
10361036

10371037
sign_string = '-' if x < 0 else ''
10381038

0 commit comments

Comments
 (0)