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

Method set_ticks

lib/matplotlib/axis.py:2334–2383  ·  view source on GitHub ↗

Set this Axis' tick locations and optionally tick labels. If necessary, the view limits of the Axis are expanded so that all given ticks are visible. Parameters ---------- ticks : 1D array-like Array of tick locations (either floats or i

(self, ticks, labels=None, *, minor=False, **kwargs)

Source from the content-addressed store, hash-verified

2332 return self.get_major_ticks(len(ticks))
2333
2334 def set_ticks(self, ticks, labels=None, *, minor=False, **kwargs):
2335 """
2336 Set this Axis' tick locations and optionally tick labels.
2337
2338 If necessary, the view limits of the Axis are expanded so that all
2339 given ticks are visible.
2340
2341 Parameters
2342 ----------
2343 ticks : 1D array-like
2344 Array of tick locations (either floats or in axis units). The axis
2345 `.Locator` is replaced by a `~.ticker.FixedLocator`.
2346
2347 Pass an empty list (``set_ticks([])``) to remove all ticks.
2348
2349 Some tick formatters will not label arbitrary tick positions;
2350 e.g. log formatters only label decade ticks by default. In
2351 such a case you can set a formatter explicitly on the axis
2352 using `.Axis.set_major_formatter` or provide formatted
2353 *labels* yourself.
2354
2355 labels : list of str, optional
2356 Tick labels for each location in *ticks*; must have the same length as
2357 *ticks*. If set, the labels are used as is, via a `.FixedFormatter`.
2358 If not set, the labels are generated using the axis tick `.Formatter`.
2359
2360 minor : bool, default: False
2361 If ``False``, set only the major ticks; if ``True``, only the minor ticks.
2362
2363 **kwargs
2364 `.Text` properties for the labels. Using these is only allowed if
2365 you pass *labels*. In other cases, please use `~.Axes.tick_params`.
2366
2367 Notes
2368 -----
2369 The mandatory expansion of the view limits is an intentional design
2370 choice to prevent the surprise of a non-visible tick. If you need
2371 other limits, you should set the limits explicitly after setting the
2372 ticks.
2373 """
2374 if labels is None and kwargs:
2375 first_key = next(iter(kwargs))
2376 raise ValueError(
2377 f"Incorrect use of keyword argument {first_key!r}. Keyword arguments "
2378 "other than 'minor' modify the text labels and can only be used if "
2379 "'labels' are passed as well.")
2380 result = self._set_tick_locations(ticks, minor=minor)
2381 if labels is not None:
2382 self.set_ticklabels(labels, minor=minor, **kwargs)
2383 return result
2384
2385 def _get_tick_boxes_siblings(self, renderer):
2386 """

Callers 7

test_fill_facecolorFunction · 0.45
colormapnorms.pyFile · 0.45
text_intro.pyFile · 0.45
demo_axes_grid.pyFile · 0.45
demo_axes_grid2.pyFile · 0.45
multiple_axes.pyFile · 0.45

Calls 2

_set_tick_locationsMethod · 0.95
set_ticklabelsMethod · 0.95

Tested by 1

test_fill_facecolorFunction · 0.36