xtickangle

Gets or sets the rotation angle of the x-axis tick labels.

Category: Graphics > Formatting and Annotation

Syntax

xtickangle(angle)

Rotates the tick labels by angle degrees.

a = xtickangle

Returns the current angle.

xtickangle(ax, ___)

Acts on the axes ax.

Description

Long tick labels, such as dates or names, can overlap when they are horizontal. Rotating them by 30 to 90 degrees makes room. The angle is stored in the property XTickLabelRotation of the axes.

Input arguments

angle
Rotation in degrees, counterclockwise. The default is 0; 90 gives vertical text.

Output arguments

a
Current rotation in degrees.

Example

Tilted labels

bar(1:4)
xticklabels({'first group', 'second group', 'third group', 'fourth group'})
xtickangle(45)
a = xtickangle
Output
a = 45

See also

ytickangle xticklabels xticks xtickformat