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

Method _raw_ticks

lib/matplotlib/ticker.py:2228–2295  ·  view source on GitHub ↗

Generate a list of tick locations including the range *vmin* to *vmax*. In some applications, one or both of the end locations will not be needed, in which case they are trimmed off elsewhere.

(self, vmin, vmax)

Source from the content-addressed store, hash-verified

2226 raise _api.kwarg_error("set_params", kwargs)
2227
2228 def _raw_ticks(self, vmin, vmax):
2229 """
2230 Generate a list of tick locations including the range *vmin* to
2231 *vmax*. In some applications, one or both of the end locations
2232 will not be needed, in which case they are trimmed off
2233 elsewhere.
2234 """
2235 if self._nbins == 'auto':
2236 if self.axis is not None:
2237 nbins = np.clip(self.axis.get_tick_space(),
2238 max(1, self._min_n_ticks - 1), 9)
2239 else:
2240 nbins = 9
2241 else:
2242 nbins = self._nbins
2243
2244 scale, offset = scale_range(vmin, vmax, nbins)
2245 _vmin = vmin - offset
2246 _vmax = vmax - offset
2247 steps = self._extended_steps * scale
2248 if self._integer:
2249 # For steps > 1, keep only integer values.
2250 igood = (steps < 1) | (np.abs(steps - np.round(steps)) < 0.001)
2251 steps = steps[igood]
2252
2253 raw_step = ((_vmax - _vmin) / nbins)
2254 if hasattr(self.axis, "axes") and self.axis.axes.name == '3d':
2255 # Due to the change in automargin behavior in mpl3.9, we need to
2256 # adjust the raw step to match the mpl3.8 appearance. The zoom
2257 # factor of 2/48, gives us the 23/24 modifier.
2258 raw_step = raw_step * 23/24
2259 large_steps = steps >= raw_step
2260 if mpl.rcParams['axes.autolimit_mode'] == 'round_numbers':
2261 # Classic round_numbers mode may require a larger step.
2262 # Get first multiple of steps that are <= _vmin
2263 floored_vmins = (_vmin // steps) * steps
2264 floored_vmaxs = floored_vmins + steps * nbins
2265 large_steps = large_steps & (floored_vmaxs >= _vmax)
2266
2267 # Find index of smallest large step
2268 if any(large_steps):
2269 istep = np.nonzero(large_steps)[0][0]
2270 else:
2271 istep = len(steps) - 1
2272
2273 # Start at smallest of the steps greater than the raw step, and check
2274 # if it provides enough ticks. If not, work backwards through
2275 # smaller steps until one is found that provides enough ticks.
2276 for step in steps[:istep+1][::-1]:
2277
2278 if (self._integer and
2279 np.floor(_vmax) - np.ceil(_vmin) >= self._min_n_ticks - 1):
2280 step = max(1, step)
2281 best_vmin = (_vmin // step) * step
2282
2283 # Find tick locations spanning the vmin-vmax range, taking into
2284 # account degradation of precision when there is a large offset.
2285 # The edge ticks beyond vmin and/or vmax are needed for the

Callers 2

tick_valuesMethod · 0.95
view_limitsMethod · 0.95

Calls 6

scale_rangeFunction · 0.85
_Edge_integerClass · 0.85
leMethod · 0.80
geMethod · 0.80
clipMethod · 0.45
get_tick_spaceMethod · 0.45

Tested by

no test coverage detected