Skip to content

Commit b27f28f

Browse files
committed
Change coeff computation for LogFormatters
1 parent c1c27b5 commit b27f28f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/matplotlib/ticker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ def __call__(self, x, pos=None):
10701070
fx = math.log(x) / math.log(b)
10711071
is_x_decade = is_close_to_int(fx)
10721072
exponent = round(fx) if is_x_decade else np.floor(fx)
1073-
coeff = round(x / b ** exponent)
1073+
coeff = round(b ** (fx - exponent))
10741074

10751075
if self.labelOnlyBase and not is_x_decade:
10761076
return ''
@@ -1154,7 +1154,7 @@ def __call__(self, x, pos=None):
11541154
fx = math.log(x) / math.log(b)
11551155
is_x_decade = is_close_to_int(fx)
11561156
exponent = round(fx) if is_x_decade else np.floor(fx)
1157-
coeff = round(x / b ** exponent)
1157+
coeff = round(b ** (fx - exponent))
11581158
if is_x_decade:
11591159
fx = round(fx)
11601160

@@ -1186,7 +1186,7 @@ def _non_decade_format(self, sign_string, base, fx, usetex):
11861186
"""Return string for non-decade locations."""
11871187
b = float(base)
11881188
exponent = math.floor(fx)
1189-
coeff = b ** fx / b ** exponent
1189+
coeff = b ** (fx - exponent)
11901190
if is_close_to_int(coeff):
11911191
coeff = round(coeff)
11921192
return r'$\mathdefault{%s%g\times%s^{%d}}$' \

0 commit comments

Comments
 (0)