matplotlib.axes.Axes.set_yticks#

Axes.set_yticks(ticks, labels=None, *, minor=False, **kwargs)[source]#

Set the yaxis' tick locations and optionally tick labels.

If necessary, the view limits of the Axis are expanded so that all given ticks are visible.

Parameters:
ticks1D array-like

Array of tick locations. The axis Locator is replaced by a FixedLocator.

The values may be either floats or in axis units.

Pass an empty list to remove all ticks:

set_yticks([])

Some tick formatters will not label arbitrary tick positions; e.g. log formatters only label decade ticks by default. In such a case you can set a formatter explicitly on the axis using Axis.set_major_formatter or provide formatted labels yourself.

labelslist of str, optional

Tick labels for each location in ticks. labels must be of the same length as ticks. If not set, the labels are generate using the axis tick Formatter.

minorbool, default: False

If False, set the major ticks; if True, the minor ticks.

**kwargs

Text properties for the labels. Using these is only allowed if you pass labels. In other cases, please use tick_params.

Notes

The mandatory expansion of the view limits is an intentional design choice to prevent the surprise of a non-visible tick. If you need other limits, you should set the limits explicitly after setting the ticks.

Examples using matplotlib.axes.Axes.set_yticks#

Bar Label Demo

Bar Label Demo

Horizontal bar chart

Horizontal bar chart

Broken Barh

Broken Barh

Power spectral density (PSD)

Power spectral density (PSD)

Creating annotated heatmaps

Creating annotated heatmaps

Programmatically controlling subplot adjustment

Programmatically controlling subplot adjustment

Rendering math equations using TeX

Rendering math equations using TeX

Make room for ylabel using axes_grid

Make room for ylabel using axes_grid

Scatter Histogram (Locatable Axes)

Scatter Histogram (Locatable Axes)

Ticklabel alignment

Ticklabel alignment

Ticklabel direction

Ticklabel direction

Integral as the area under a curve

Integral as the area under a curve

Shaded & power normalized rendering

Shaded & power normalized rendering

XKCD

XKCD

Rain simulation

Rain simulation

MATPLOTLIB UNCHAINED

MATPLOTLIB UNCHAINED

Create 2D bar graphs in different planes

Create 2D bar graphs in different planes

SkewT-logP diagram: using transforms and custom projections

SkewT-logP diagram: using transforms and custom projections

Axis ticks

Axis ticks