This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Set or query x-axis tick labels


xl = xticklabels
m = xticklabels('mode')
___ = xticklabels(ax,___)



xticklabels(labels) sets the x-axis tick labels for the current axes. Specify labels as a string array or a cell array of character vectors; for example, {'January','February','March'}. If you specify the labels, then the x-axis tick values and tick labels no longer update automatically based on changes to the axes.

xl = xticklabels returns the x-axis tick labels for the current axes.


xticklabels('auto') sets an automatic mode, enabling the axes to determine the x-axis tick labels. Use this option if you set the labels and then want to set them back to the default values.

xticklabels('manual') sets a manual mode, freezing the x-axis tick labels at the current values.

m = xticklabels('mode') returns the current value of the x-axis tick labels mode, which is either 'auto' or 'manual'. By default, the mode is automatic unless you specify the tick labels or set the mode to manual.


___ = xticklabels(ax,___) uses the axes specified by ax instead of the current axes. Specify ax as the first input argument for any of the previous syntaxes.


collapse all

Create a line plot. Display tick marks along the x-axis at the values 0, 5, and 10. Then specify a label for each tick mark.

x = linspace(0,10);
y = x.^2;
xticks([0 5 10])
xticklabels({'x = 0','x = 5','x = 10'})

Create a line plot. Specify the x-axis limits and display tick marks along at the x-axis at increments of .

x = linspace(0,6*pi);
y = sin(x);
xlim([0 6*pi])

MATLAB® labels the tick marks with the numeric values. Change the labels to show the symbol by specifying text for each label.


Create a figure with two subplots and return the axes objects as ax1 and ax2. Plot random data in each subplot. Set the x-axis tick values and labels for the second subplot by specifying ax2 as the first input argument.

ax1 = subplot(2,1,1);

ax2 = subplot(2,1,2);
xticks(ax2,[1 2 3])

Create a stem chart, and specify the x-axis tick values and corresponding labels. Then set the x-axis tick values and labels back to the default values.

xticks([1 4 6 10])


Remove the tick labels along the x-axis by specifying the tick labels as an empty array.


Input Arguments

collapse all

Tick labels, specified as a cell array of character vectors or a string array. If you do not want tick labels to show, then specify an empty cell array {}. Tick labels support TeX and LaTeX markup. See the TickLabelInterpreter property of the Axes object for more information.

Example: xticklabels({'0','\pi','2\pi'})

Example: xticklabels({'January','Febrary','March'})

Example: xticklabels({})


To specify the tick values, use the xticks function.

Target axes, specified as a single Axes object or a vector of Axes objects. If you do not specify the axes, then xticklabels uses the current axes.

Output Arguments

collapse all

Current tick labels, returned as a cell array of character vectors or a character array.

Current tick labels mode, returned as one of these values:

  • 'auto' — Automatically determine the x-axis tick labels.

  • 'manual' — Use manually specified x-axis tick labels.

More About

collapse all

Tick Labels

The tick labels are the labels that you see next to each tick mark. The tick values are the locations along the x-axis where the tick marks appear. Set the values using the xticks function. Set the corresponding labels using the xticklabels function.


The xticklabels function sets and queries several axes properties related to the x-axis tick labels.

  • XTickLabel — Property that stores the text for the x-axis tick labels.

  • XTickLabelMode — Property that stores the x-axis tick label mode. When you set the x-axis tick labels using xticklabels, this property changes to 'manual'.

  • XTickMode — Property that stores the x-axis tick value mode. When you set the x-axis tick labels using xticklabels, this property changes to 'manual'.

Introduced in R2016b

Was this topic helpful?