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
3 changes: 1 addition & 2 deletions lib/matplotlib/tests/test_ticker.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

from numpy.testing import assert_almost_equal
import numpy as np
import pytest
Expand Down Expand Up @@ -305,6 +303,7 @@ def test_LogFormatterExponent_blank():
def test_LogFormatterSciNotation():
test_cases = {
10: (
(-1, '${-10^{0}}$'),
(1e-05, '${10^{-5}}$'),
(1, '${10^{0}}$'),
(100000, '${10^{5}}$'),
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,15 @@ def __call__(self, x, pos=None):
if x == 0.0:
return '0'
sign = np.sign(x)
x = abs(x)
# only label the decades
fx = math.log(abs(x)) / math.log(b)
fx = math.log(x) / math.log(b)
isDecade = is_close_to_int(fx)
exponent = np.round(fx) if isDecade else np.floor(fx)
coeff = np.round(x / b ** exponent)
if coeff in self.sublabel:
if not isDecade and self.labelOnlyBase:
s = ''
return ''
elif x > 10000:
s = '%1.0e' % x
elif x < 1:
Expand Down Expand Up @@ -1032,7 +1033,7 @@ def __call__(self, x, pos=None):
fx = math.log(abs(x)) / math.log(b)
is_decade = is_close_to_int(fx)
exponent = np.round(fx) if is_decade else np.floor(fx)
coeff = np.round(x / b ** exponent)
coeff = np.round(abs(x) / b ** exponent)

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

Expand Down