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

Method __call__

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

Source from the content-addressed store, hash-verified

1074 return self._pprint_val(x, vmax - vmin) if 1 <= x <= 10000 else f"{x:1.0e}"
1075
1076 def __call__(self, x, pos=None):
1077 # docstring inherited
1078 if x == 0.0: # Symlog
1079 return '0'
1080
1081 x = abs(x)
1082 b = self._base
1083 # only label the decades
1084 fx = math.log(x) / math.log(b)
1085 is_x_decade = _is_close_to_int(fx)
1086 exponent = round(fx) if is_x_decade else np.floor(fx)
1087 coeff = round(b ** (fx - exponent))
1088
1089 if self.labelOnlyBase and not is_x_decade:
1090 return ''
1091 if self._sublabels is not None and coeff not in self._sublabels:
1092 return ''
1093
1094 vmin, vmax = self.axis.get_view_interval()
1095 vmin, vmax = mtransforms._nonsingular(vmin, vmax, expander=0.05)
1096 s = self._num_to_string(x, vmin, vmax)
1097 return self.fix_minus(s)
1098
1099 def format_data(self, value):
1100 with cbook._setattr_cm(self, labelOnlyBase=False):

Callers 1

format_dataMethod · 0.95

Calls 4

_num_to_stringMethod · 0.95
_is_close_to_intFunction · 0.85
fix_minusMethod · 0.80
get_view_intervalMethod · 0.45

Tested by

no test coverage detected