matplotlib.pyplot.yticks#
- matplotlib.pyplot.yticks(ticks=None, labels=None, *, minor=False, **kwargs)[source]#
 Get or set the current tick locations and labels of the y-axis.
Pass no arguments to return the current values without modifying them.
- Parameters:
 - ticksarray-like, optional
 The list of ytick locations. Passing an empty list removes all yticks.
- labelsarray-like, optional
 The labels to place at the given ticks locations. This argument can only be passed if ticks is passed as well.
- minorbool, default: False
 If
False, get/set the major ticks/labels; ifTrue, the minor ticks/labels.- **kwargs
 Textproperties can be used to control the appearance of the labels.Warning
This only sets the properties of the current ticks, which is only sufficient if you either pass ticks, resulting in a fixed list of ticks, or if the plot is static.
Ticks are not guaranteed to be persistent. Various operations can create, delete and modify the Tick instances. There is an imminent risk that these settings can get lost if you work on the figure further (including also panning/zooming on a displayed figure).
Use
tick_paramsinstead if possible.
- Returns:
 - locs
 The list of ytick locations.
- labels
 The list of ylabel
Textobjects.
Notes
Calling this function with no arguments (e.g.
yticks()) is the pyplot equivalent of callingget_yticksandget_yticklabelson the current Axes. Calling this function with arguments is the pyplot equivalent of callingset_yticksandset_yticklabelson the current Axes.Examples
>>> locs, labels = yticks() # Get the current locations and labels. >>> yticks(np.arange(0, 1, step=0.2)) # Set label locations. >>> yticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels. >>> yticks([0, 1, 2], ['January', 'February', 'March'], ... rotation=45) # Set text labels and properties. >>> yticks([]) # Disable yticks.