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

Function xticks

lib/matplotlib/pyplot.py:2314–2397  ·  view source on GitHub ↗

Get or set the current tick locations and labels of the x-axis. Pass no arguments to return the current values without modifying them. Parameters ---------- ticks : array-like, optional The list of xtick locations. Passing an empty list removes all xticks. labels

(
    ticks: ArrayLike | None = None,
    labels: Sequence[str] | None = None,
    *,
    minor: bool = False,
    **kwargs
)

Source from the content-addressed store, hash-verified

2312
2313
2314def xticks(
2315 ticks: ArrayLike | None = None,
2316 labels: Sequence[str] | None = None,
2317 *,
2318 minor: bool = False,
2319 **kwargs
2320) -> tuple[list[Tick] | np.ndarray, list[Text]]:
2321 """
2322 Get or set the current tick locations and labels of the x-axis.
2323
2324 Pass no arguments to return the current values without modifying them.
2325
2326 Parameters
2327 ----------
2328 ticks : array-like, optional
2329 The list of xtick locations. Passing an empty list removes all xticks.
2330 labels : array-like, optional
2331 The labels to place at the given *ticks* locations. This argument can
2332 only be passed if *ticks* is passed as well.
2333 minor : bool, default: False
2334 If ``False``, get/set the major ticks/labels; if ``True``, the minor
2335 ticks/labels.
2336 **kwargs
2337 `.Text` properties can be used to control the appearance of the labels.
2338
2339 .. warning::
2340
2341 This only sets the properties of the current ticks, which is
2342 only sufficient if you either pass *ticks*, resulting in a
2343 fixed list of ticks, or if the plot is static.
2344
2345 Ticks are not guaranteed to be persistent. Various operations
2346 can create, delete and modify the Tick instances. There is an
2347 imminent risk that these settings can get lost if you work on
2348 the figure further (including also panning/zooming on a
2349 displayed figure).
2350
2351 Use `~.pyplot.tick_params` instead if possible.
2352
2353
2354 Returns
2355 -------
2356 locs
2357 The list of xtick locations.
2358 labels
2359 The list of xlabel `.Text` objects.
2360
2361 Notes
2362 -----
2363 Calling this function with no arguments (e.g. ``xticks()``) is the pyplot
2364 equivalent of calling `~.Axes.get_xticks` and `~.Axes.get_xticklabels` on
2365 the current Axes.
2366 Calling this function with arguments is the pyplot equivalent of calling
2367 `~.Axes.set_xticks` and `~.Axes.set_xticklabels` on the current Axes.
2368
2369 Examples
2370 --------
2371 >>> locs, labels = xticks() # Get the current locations and labels.

Callers

nothing calls this directly

Calls 3

gcaFunction · 0.85
set_xticksMethod · 0.80
_internal_updateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…