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

Method _format_value

lib/matplotlib/ticker.py:1341–1365  ·  view source on GitHub ↗
(self, x, locs, sci_notation=True)

Source from the content-addressed store, hash-verified

1339 self._labelled.update(locs[i] for i in good_minor)
1340
1341 def _format_value(self, x, locs, sci_notation=True):
1342 if sci_notation:
1343 exponent = math.floor(np.log10(x))
1344 min_precision = 0
1345 else:
1346 exponent = 0
1347 min_precision = 1
1348 value = x * 10 ** (-exponent)
1349 if len(locs) < 2:
1350 precision = min_precision
1351 else:
1352 diff = np.sort(np.abs(locs - x))[1]
1353 precision = -np.log10(diff) + exponent
1354 precision = (
1355 int(np.round(precision))
1356 if _is_close_to_int(precision)
1357 else math.ceil(precision)
1358 )
1359 if precision < min_precision:
1360 precision = min_precision
1361 mantissa = r"%.*f" % (precision, value)
1362 if not sci_notation:
1363 return mantissa
1364 s = r"%s\cdot10^{%d}" % (mantissa, exponent)
1365 return s
1366
1367 def _one_minus(self, s):
1368 if self._use_overline:

Callers 1

__call__Method · 0.95

Calls 1

_is_close_to_intFunction · 0.85

Tested by

no test coverage detected