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

Method format_data

lib/matplotlib/ticker.py:752–766  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

750 return self._format_maybe_minus_and_locale(fmt, value)
751
752 def format_data(self, value):
753 # docstring inherited
754 e = math.floor(math.log10(abs(value)))
755 s = round(value / 10**e, 10)
756 significand = self._format_maybe_minus_and_locale(
757 "%d" if s % 1 == 0 else "%1.10g", s)
758 if e == 0:
759 return significand
760 exponent = self._format_maybe_minus_and_locale("%d", e)
761 if self._useMathText or self._usetex:
762 exponent = "10^{%s}" % exponent
763 return (exponent if s == 1 # reformat 1x10^y as 10^y
764 else rf"{significand} \times {exponent}")
765 else:
766 return f"{significand}e{exponent}"
767
768 def get_offset(self):
769 """

Callers 2

get_offsetMethod · 0.95
test_format_dataMethod · 0.95

Calls 1

Tested by 1

test_format_dataMethod · 0.76