yticks

Gets or sets the positions of the y-axis tick marks.

Category: Graphics > Formatting and Annotation

Syntax

yticks(ticks)

Sets the tick positions to the values in the vector ticks.

t = yticks

Returns the current tick positions.

yticks('auto')

Goes back to automatic tick placement.

yticks(ax, ___)

Acts on the axes ax.

Description

By default the axes choose round tick values that depend on the limits. yticks fixes them instead, which is useful to mark the points where data were sampled or the multiples of pi on a trigonometric plot. The positions are stored in the YTick property.

Pair it with yticklabels to give the ticks custom text.

Input arguments

ticks
Vector of increasing values. An empty vector [] removes the ticks.

Output arguments

t
Row vector with the current tick positions.

Example

Fixed tick positions

plot(1:5, [2 8 5 9 4])
yticks(0:3:9)
t = yticks
Output
t = 1×4

     0     3     6     9

See also

xticks yticklabels ylim ytickangle grid