MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / __call__

Method __call__

lib/matplotlib/ticker.py:1154–1189  ·  view source on GitHub ↗
(self, x, pos=None)

Source from the content-addressed store, hash-verified

1152 return r'$\mathdefault{%s%s^{%.2f}}$' % (sign_string, base, fx)
1153
1154 def __call__(self, x, pos=None):
1155 # docstring inherited
1156 if x == 0: # Symlog
1157 return r'$\mathdefault{0}$'
1158
1159 sign_string = '-' if x < 0 else ''
1160 x = abs(x)
1161 b = self._base
1162
1163 # only label the decades
1164 fx = math.log(x) / math.log(b)
1165 is_x_decade = _is_close_to_int(fx)
1166 exponent = round(fx) if is_x_decade else np.floor(fx)
1167 coeff = round(b ** (fx - exponent))
1168
1169 if self.labelOnlyBase and not is_x_decade:
1170 return ''
1171 if self._sublabels is not None and coeff not in self._sublabels:
1172 return ''
1173
1174 if is_x_decade:
1175 fx = round(fx)
1176
1177 # use string formatting of the base if it is not an integer
1178 if b % 1 == 0.0:
1179 base = '%d' % b
1180 else:
1181 base = '%s' % b
1182
1183 if abs(fx) < mpl.rcParams['axes.formatter.min_exponent']:
1184 return r'$\mathdefault{%s%g}$' % (sign_string, x)
1185 elif not is_x_decade:
1186 usetex = mpl.rcParams['text.usetex']
1187 return self._non_decade_format(sign_string, base, fx, usetex)
1188 else:
1189 return r'$\mathdefault{%s%s^{%d}}$' % (sign_string, base, fx)
1190
1191
1192class LogFormatterSciNotation(LogFormatterMathtext):

Callers

nothing calls this directly

Calls 2

_non_decade_formatMethod · 0.95
_is_close_to_intFunction · 0.85

Tested by

no test coverage detected