subtitle — Set subtitle text for the current axes or a specified axes handle with MATLAB-compatible subtitle forms.
subtitle attaches secondary title text to individual axes and returns a text handle for property updates. It follows MATLAB-compatible axes-scoped behavior and is separate from figure-level title helpers such as sgtitle and suptitle.
Syntax
h = subtitle(txt)
h = subtitle(ax, txt)
h = subtitle(txt, Name, Value, ...)
h = subtitle(ax, txt, Name, Value, ...)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
txt | Any | Yes | — | Subtitle text (string/char/cellstr-like multiline forms). |
ax | AxesHandle | Yes | — | Target axes handle. |
props | Any | Variadic | — | Property/value pairs (Color, FontSize, FontWeight, etc.). |
Returns
| Name | Type | Description |
|---|---|---|
h | NumericScalar | Handle to the created/updated subtitle object. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:subtitle:InvalidArgument | Axes handle, text payload, or property/value arguments are invalid. | subtitle: invalid argument |
RunMat:subtitle:Internal | Internal plotting state update fails. | subtitle: internal operation failed |
How subtitle works
- The returned value is a text handle that can be inspected or updated through
getandset. - With no explicit target,
subtitleattaches text to the current axes as returned bygca. - Passing an axes handle as the first argument targets that specific axes, which is useful in subplot layouts.
- String scalars, char arrays, string arrays, and cell arrays are all accepted. String arrays and cell arrays produce multiline subtitles, with elements joined by newlines.
- Text styling properties such as
FontSize,FontWeight,FontAngle,Color,Interpreter, andVisibleuse the shared plotting text-property system. FontSizeaccepts every native integer class as well as floating-point scalars. The value crosses the graphics floating boundary only after exact scalar validation.- Axes handles are normally the double handles returned by plotting functions. Typed-integer aliases for encoded axes handles are available only when RunMat extensions are enabled and are rejected in strict compatibility mode before graphics state changes.
get(ax, 'Subtitle')returns the subtitle text handle for that axes.get(h, 'String')returns the subtitle text for the subtitle handle.
Examples
Add a title and subtitle to the current axes
plot(0:0.1:2*pi, sin(0:0.1:2*pi));
title('Sine Wave');
subtitle('One period sampled every 0.1 radians');Expected output:
% title and subtitle are rendered above the axesStyle the subtitle and inspect its handle
plot(1:10, rand(1, 10));
h = subtitle('Trial A', 'FontSize', 12, 'FontWeight', 'bold');
get(h, 'Type')Expected output:
ans =
'text'Set independent subtitles on subplot panels
ax1 = subplot(1, 2, 1);
plot(ax1, 1:5, 1:5);
ax2 = subplot(1, 2, 2);
plot(ax2, 1:5, (1:5).^2);
subtitle(ax1, 'Linear response');
subtitle(ax2, 'Quadratic response');Expected output:
% Subtitles are attached to their respective axesCreate a multiline subtitle from a cell array
plot(1:5, [2 4 1 3 5]);
subtitle({'Experiment 7', 'Filtered signal'});Expected output:
% Both cell elements appear as separate subtitle linesUpdate a subtitle after plotting using set
plot(1:10, rand(1, 10));
h = subtitle('Draft');
set(h, 'String', 'Final Subtitle', 'Color', 'r');Expected output:
% The axes subtitle is updated in placeUsing subtitle with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how subtitle changes the result.
Run a small subtitle example, explain the result, then change one input and compare the output.
FAQ
How is subtitle different from title?⌄
title sets the primary axes title. subtitle sets a second text line associated with the same axes and is rendered below the primary title when both are present.
Can I target a specific subplot?⌄
Yes. Pass the axes handle returned by subplot or gca as the first argument.
ax = subplot(2, 1, 1);
subtitle(ax, 'Top panel details');Can I update the subtitle after creating it?⌄
Yes. subtitle returns a text handle, so you can update it with set.
h = subtitle('Initial');
set(h, 'String', 'Updated', 'FontSize', 12);Can FontSize be an integer value?⌄
Yes. All eight native integer classes are accepted for FontSize, and practical positive sizes are validated exactly before entering the renderer's floating-point graphics domain.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · axes · barh · caxis · cla · clf · clim · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · suptitle · text · textscatter · textscatter3 · triplot · waitbar · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
More plotting resources
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how subtitle is executed, line by line, in Rust.
- View the source for subtitle in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.