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

Method set_locs

lib/matplotlib/ticker.py:1004–1071  ·  view source on GitHub ↗

Use axis view limits to control which ticks are labeled. The *locs* parameter is ignored in the present algorithm.

(self, locs=None)

Source from the content-addressed store, hash-verified

1002 self.labelOnlyBase = labelOnlyBase
1003
1004 def set_locs(self, locs=None):
1005 """
1006 Use axis view limits to control which ticks are labeled.
1007
1008 The *locs* parameter is ignored in the present algorithm.
1009 """
1010 if np.isinf(self.minor_thresholds[0]):
1011 self._sublabels = None
1012 return
1013
1014 # Handle symlog case:
1015 linthresh = self._linthresh
1016 if linthresh is None:
1017 try:
1018 linthresh = self.axis.get_transform().linthresh
1019 except AttributeError:
1020 pass
1021
1022 vmin, vmax = self.axis.get_view_interval()
1023 if vmin > vmax:
1024 vmin, vmax = vmax, vmin
1025
1026 if linthresh is None and vmin <= 0:
1027 # It's probably a colorbar with
1028 # a format kwarg setting a LogFormatter in the manner
1029 # that worked with 1.5.x, but that doesn't work now.
1030 self._sublabels = {1} # label powers of base
1031 return
1032
1033 b = self._base
1034
1035 if linthresh is not None: # symlog
1036 # Only count ticks and decades in the logarithmic part of the axis.
1037 numdec = numticks = 0
1038 if vmin < -linthresh:
1039 rhs = min(vmax, -linthresh)
1040 numticks += (
1041 math.floor(math.log(abs(rhs), b))
1042 - math.floor(math.nextafter(math.log(abs(vmin), b), -math.inf)))
1043 numdec += math.log(vmin / rhs, b)
1044 if vmax > linthresh:
1045 lhs = max(vmin, linthresh)
1046 numticks += (
1047 math.floor(math.log(vmax, b))
1048 - math.floor(math.nextafter(math.log(lhs, b), -math.inf)))
1049 numdec += math.log(vmax / lhs, b)
1050 else:
1051 lmin = math.log(vmin, b)
1052 lmax = math.log(vmax, b)
1053 # The nextafter call handles the case where vmin is exactly at a
1054 # decade (e.g. there's one major tick between 1 and 5).
1055 numticks = (math.floor(lmax)
1056 - math.floor(math.nextafter(lmin, -math.inf)))
1057 numdec = abs(lmax - lmin)
1058
1059 if numticks > self.minor_thresholds[0]:
1060 # Label only bases
1061 self._sublabels = {1}

Callers

nothing calls this directly

Calls 2

get_transformMethod · 0.45
get_view_intervalMethod · 0.45

Tested by

no test coverage detected