8000 Merge pull request #7337 from NelleV/7211_symlog · matplotlib/matplotlib@1f38ea6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f38ea6

Browse files
authored
Merge pull request #7337 from NelleV/7211_symlog
FIX symlog scale now shows negative labels.
2 parents e794622 + 0199251 commit 1f38ea6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 1 addition & 2 deletions
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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,14 +898,15 @@ def __call__(self, x, pos=None):
898898
if x == 0.0:
899899
return '0'
900900
sign = np.sign(x)
901+
x = abs(x)
901902
# only label the decades
902-
fx = math.log(abs(x)) / math.log(b)
903+
fx = math.log(x) / math.log(b)
903904
isDecade = is_close_to_int(fx)
904905
exponent = np.round(fx) if isDecade else np.floor(fx)
905906
coeff = np.round(x / b ** exponent)
906907
if coeff in self.sublabel:
907908
if not isDecade and self.labelOnlyBase:
908-
s = ''
909+
return ''
909910
elif x > 10000:
910911
s = '%1.0e' % x
911912
elif x < 1:
@@ -1032,7 +1033,7 @@ def __call__(self, x, pos=None):
10321033
fx = math.log(abs(x)) / math.log(b)
10331034
is_decade = is_close_to_int(fx)
10341035
exponent = np.round(fx) if is_decade else np.floor(fx)
1035-
coeff = np.round(x / b ** exponent)
1036+
coeff = np.round(abs(x) / b ** exponent)
10361037

10371038
sign_string = '-' if x < 0 else ''
10381039

0 commit comments

Comments
 (0)
0