xlabel
Adds a label to the x-axis.
Category: Graphics > Formatting and Annotation
Syntax
xlabel(txt)
Sets the x-axis label of the current axes.
xlabel(txt, Name, Value)
Sets text properties such as 'FontSize' or 'Color'.
xlabel(target, ___)
Labels the axes or tiled layout target.
t = xlabel(___)
Returns the text object.
Description
The label is centered under the x-axis. It is stored in the axes as XLabel, so a second call replaces the first. TeX markup such as \alpha or t_{max} is interpreted by default.
With a tiled layout as target, the label is shared by the whole grid and appears once under it.
Input arguments
txt- Label as text, a string array or a cell array of lines (a multi-line label).
Output arguments
t- Text object, class
matlab.graphics.primitive.Text.
Example
Label with units and TeX
t = 0:0.1:5;
plot(t, exp(-t))
h = xlabel('time t (s)');
ylabel('\alpha(t)')
h.String
Output
ans = 'time t (s)'