You are reading an old version of the documentation (v3.1.0). For the latest version see
Version 3.1.0
Fork me on GitHub

Table of Contents


matplotlib.pyplot.yticks(ticks=None, labels=None, **kwargs)[source]

Get or set the current tick locations and labels of the y-axis.

Call signatures:

locs, labels = yticks()            # Get locations and labels
yticks(ticks, [labels], **kwargs)  # Set locations and labels
ticks : array_like

A list of positions at which ticks should be placed. You can pass an empty list to disable yticks.

labels : array_like, optional

A list of explicit labels to place at the given locs.


Text properties can be used to control the appearance of the labels.


An array of label locations.


A list of Text objects.


Calling this function with no arguments (e.g. yticks()) is the pyplot equivalent of calling get_yticks and get_yticklabels on the current axes. Calling this function with arguments is the pyplot equivalent of calling set_yticks and set_yticklabels on the current axes.


Get the current locations and labels:

>>> locs, labels = yticks()

Set label locations:

>>> yticks(np.arange(0, 1, step=0.2))

Set text labels:

>>> yticks(np.arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue'))

Set text labels and properties:

>>> yticks(np.arange(12), calendar.month_name[1:13], rotation=45)

Disable yticks:

>>> yticks([])