Written and maintained by CASRAI Editorial Board
Last updated
Short answer: in MATLAB you label a plot with xlabel and ylabel for the axes, title for the heading, legend for series names and text for labels placed at individual data points. Each takes the text first and optional Name=Value pairs after it, for example xlabel("My Label",Color="red",FontSize=12). This guide is for researchers and analysts who have a plot on screen and need it to carry units, a title and readable annotations before it goes into a paper, poster or report.
What plot labels are used for in research
An unlabelled figure cannot be interpreted on its own: readers need the quantity and unit on each axis, a title or caption that states what is shown, and a legend or point labels that identify each series or observation. MATLAB provides one function per job, and all of them are documented in the MATLAB reference pages listed under Sources. For the wider workflow of building and exporting a figure, see plotting a graph in MATLAB and graphing in MATLAB.
Install or access (official source only)
MATLAB is a MathWorks product, and the label functions on this page ship with base MATLAB; no extra toolbox is named on their reference pages. Obtain MATLAB from MathWorks or through your institution’s licence, and use the MathWorks documentation for your installed release. If you want a general orientation first, read what MATLAB is used for.
Step-by-step: label a plot
- Create the plot. For example
x = 1:5; y = x.^2; plot(x,y,'o-'). - Label the axes.
xlabel('Time (s)')andylabel('Displacement (m)'). Both accept the same syntax:xlabel(txt),xlabel(target,txt),xlabel(___,Name=Value)andt = xlabel(___). The optionaltargetis the axes (or tiled layout, or a standalone chart that has anXLabelproperty) to label. - Add a title, and optionally a subtitle.
title('Displacement over time'), ortitle('Displacement over time','Trial 3')to add a subtitle underneath. The formstitle(target,___)and[t,s] = title(___)let you choose the axes and keep handles to the title and subtitle. - Name the series. Either list the names in order,
legend('Jan','Feb','Mar'), or set'DisplayName'on each series and calllegendwith no arguments. To list only some series, pass their handles first:legend([p1 p3],{'First','Third'}). - Label individual points.
text(x,y,txt)places text at the coordinates given. Ifxandyare vectors andtxtis a cell array with one string per point, each point gets its own label:text(x,y,{'A','B','C','D','E'}). A single string is repeated at every point. In 3-D axes usetext(x,y,z,txt); see 3-D plots in MATLAB. - Adjust appearance. Use
Name=Valuepairs:FontSize(default 11 points),FontWeight('normal'or'bold'),FontName,Color(default[0.15 0.15 0.15]; accepts an RGB triplet, a hex colour or a colour name) andRotationin degrees (positive is counterclockwise). To colour the data itself rather than the text, see plot colours and line styles.
TeX and LaTeX in labels
The Interpreter property controls how label text is read. Its default is "tex"; the alternatives are "latex" and "none".
- TeX (default):
^{ }gives a superscript and_{ }a subscript;bf,it,slandrmchange the font style;fontname{..},fontsize{..}andcolor{..}change the font inside the string; Greek and symbols such asalpha,leqandpiare supported. Example:ylabel('Rate alpha_{0} (s^{-1})'). - LaTeX: wrap inline maths in single dollar signs and display maths in double dollar signs, and set the interpreter:
xlabel('$x^{2}$','Interpreter','latex'). The LaTeX text is limited to 1200 characters (each additional line reduces that allowance by about 10). With the LaTeX interpreter,FontName,FontWeightandFontAnglehave no effect. - None: use
"none"when the text contains characters such as_or^that you want printed literally.
Labelling tiled layouts
The target argument is how you label one plot among several. With tiledlayout(2,1); ax1 = nexttile; plot((1:10).^2); xlabel(ax1,'Population') the label goes on the first tile’s axes only. A TiledChartLayout can itself be the target of xlabel, ylabel and title, which gives the whole layout a shared label or title. For the older subplot approach see subplots in MATLAB.
Output and how to read it
| Call | What appears | Handle returned |
|---|---|---|
xlabel, ylabel |
Text beside the x- or y-axis | t = xlabel(___) |
title |
Text above the axes; a second argument adds a subtitle underneath. Default font size is 11 for the title text; the axes title otherwise follows the axes font size (10) times TitleFontSizeMultiplier (1.1) |
t = title(___) or [t,s] = title(___) |
legend |
Key mapping each series to a name; entries come from DisplayName, and an empty DisplayName gives an entry of the form dataN |
Legend object |
text |
Text at data coordinates, one string per point when given a cell array | t = text(___) |
Keep the returned handle if you will change the label later: setting properties on it, for example t.FontSize = 14, edits the existing label instead of creating a new one. The legend updates automatically when series are added or deleted unless its AutoUpdate property is set to 'off'. To leave one item (such as a reference line) out of the legend, pass an empty label in its place, as in legend('sin(x)','sin(x+1)','').
Troubleshooting
- The font or colour change has no effect. MathWorks states that modifying the label appearance is not supported for all types of charts, and standalone visualizations do not support appearance changes. Check whether your chart type supports it, or label the axes of a standard plot instead.
- The font name or weight is ignored. With
Interpreterset to"latex",FontName,FontWeightandFontAnglehave no effect; set the style inside the LaTeX string or return to"tex". - A long LaTeX label. Keep LaTeX label text within 1200 characters, and remember multi-line text reduces the allowance.
- Underscores become subscripts. The default interpreter is TeX. Set
Interpreterto"none"for literal text. - The label lands on the wrong plot. When a figure has more than one axes, pass the axes (or tiled layout) as the first argument.
- Legend shows data1, data2. The series have no
DisplayName; set it when plotting or pass the names tolegend.
Free alternatives
| Tool | Axis label | Title | Text at a point |
|---|---|---|---|
| GNU Octave | xlabel (string), ylabel (string), also xlabel (hax, ...) |
title (string) |
text (x, y, string) |
| Python Matplotlib | Axes.set_xlabel(xlabel, fontdict=None, labelpad=None, *, loc=None, **kwargs), with loc one of ‘left’, ‘center’, ‘right’ |
Axes.set_title |
Not covered on this page; see the Matplotlib documentation |
Octave’s documentation describes xlabel as specifying the string used to label the x-axis of the current axis. Matplotlib’s set_xlabel takes a labelpad in points (default 4.0) and text properties as keyword arguments.
FAQ
How do I add a label to a MATLAB plot?
Call xlabel('text') and ylabel('text') after plotting, title('text') for a heading, and text(x,y,'text') for a label at a chosen point.
How do I put a subscript or Greek letter in an axis label?
Use TeX syntax in the default interpreter: _{ } for subscripts, ^{ } for superscripts and names such as alpha for Greek letters. For full equations use Interpreter "latex" with the text inside dollar signs.
How do I label every point on a scatter or line plot?
Pass vectors x and y and a cell array with one string per point to text.
How do I change the label font size or colour?
Add FontSize and Color as Name=Value pairs, for example xlabel("My Label",Color="red",FontSize=12). The default size is 11 points.
How do I label one subplot or tile?
Pass that axes as the first argument, for example xlabel(ax1,'Population').
Sources (official documentation)
MathWorks documentation pages read 2026-11-07; check the page for your installed release.







