ylabel

Adds a label to the y-axis.

Category: Graphics > Formatting and Annotation

Syntax

ylabel(txt)

Sets the y-axis label of the current axes.

ylabel(txt, Name, Value)

Sets text properties such as 'FontSize' or 'Color'.

ylabel(target, ___)

Labels the axes or tiled layout target.

t = ylabel(___)

Returns the text object.

Description

The label is rotated 90 degrees and placed beside the y-axis. It is stored in the axes as YLabel, 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.

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

t = 0:0.1:5;
plot(t, 9.8*t)
h = ylabel('speed v (m/s)');
xlabel('time t (s)')
h.String
Output
ans = 'speed v (m/s)'

See also

xlabel title ylim yticks text