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

Method format_data_short

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

Source from the content-addressed store, hash-verified

722 self._powerlimits = lims
723
724 def format_data_short(self, value):
725 # docstring inherited
726 if value is np.ma.masked:
727 return ""
728 if isinstance(value, Integral):
729 fmt = "%d"
730 else:
731 if getattr(self.axis, "__name__", "") in ["xaxis", "yaxis"]:
732 if self.axis.__name__ == "xaxis":
733 axis_trf = self.axis.axes.get_xaxis_transform()
734 axis_inv_trf = axis_trf.inverted()
735 screen_xy = axis_trf.transform((value, 0))
736 neighbor_values = axis_inv_trf.transform(
737 screen_xy + [[-1, 0], [+1, 0]])[:, 0]
738 else: # yaxis:
739 axis_trf = self.axis.axes.get_yaxis_transform()
740 axis_inv_trf = axis_trf.inverted()
741 screen_xy = axis_trf.transform((0, value))
742 neighbor_values = axis_inv_trf.transform(
743 screen_xy + [[0, -1], [0, +1]])[:, 1]
744 delta = abs(neighbor_values - value).max()
745 else:
746 # Rough approximation: no more than 1e4 divisions.
747 a, b = self.axis.get_view_interval()
748 delta = (b - a) / 1e4
749 fmt = f"%-#.{cbook._g_sig_digits(value, delta)}g"
750 return self._format_maybe_minus_and_locale(fmt, value)
751
752 def format_data(self, value):
753 # docstring inherited

Callers

nothing calls this directly

Calls 7

maxMethod · 0.80
get_xaxis_transformMethod · 0.45
invertedMethod · 0.45
transformMethod · 0.45
get_yaxis_transformMethod · 0.45
get_view_intervalMethod · 0.45

Tested by

no test coverage detected