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

NameTypeRequiredDefaultDescription
txtAnyYesSubtitle text (string/char/cellstr-like multiline forms).
axAxesHandleYesTarget axes handle.
propsAnyVariadicProperty/value pairs (Color, FontSize, FontWeight, etc.).

Returns

NameTypeDescription
hNumericScalarHandle to the created/updated subtitle object.

Errors

IdentifierWhenMessage
RunMat:subtitle:InvalidArgumentAxes handle, text payload, or property/value arguments are invalid.subtitle: invalid argument
RunMat:subtitle:InternalInternal 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 get and set.
  • With no explicit target, subtitle attaches text to the current axes as returned by gca.
  • 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, and Visible use the shared plotting text-property system.
  • 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 axes

Style 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 axes

Create 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 lines

Update 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 place

Using 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);

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.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.