RunMat
GitHub

title — Set the title of the current axes or a specified axes handle.

title attaches a text label to the top of the current axes. It returns a text handle that participates in the shared plotting property system used by get and set. Unlike sgtitle, which is figure-scoped, title is axes-scoped: in a subplot layout, each panel gets its own independent title.

How title works

  • The returned value is a text handle that can be inspected or updated through get and set.
  • With no explicit target, title 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 titles, with elements joined by newlines.
  • Text styling properties — FontSize, FontWeight, FontAngle, Color, Interpreter, and Visible — use the shared plotting text-property system.
  • Passing an unrecognized property name raises an error. Passing a non-numeric value for FontSize raises an error.

Examples

Add a title to the current axes

plot(0:0.1:2*pi, sin(0:0.1:2*pi));
title('Sine Wave');

Expected output:

% title is rendered above the axes

Style the title and inspect its handle

plot(1:10, rand(1, 10));
h = title('Random Signal', 'FontSize', 16, 'FontWeight', 'bold');
get(h, 'Type')

Expected output:

ans =
    'text'

Set an independent title on each subplot panel

subplot(1, 2, 1);
plot(0:0.1:pi, sin(0:0.1:pi));
title('Sine');
subplot(1, 2, 2);
plot(0:0.1:pi, cos(0:0.1:pi));
title('Cosine');

Expected output:

% Each panel has its own title; the figure has none

Target a specific axes using an explicit handle

ax1 = subplot(1, 2, 1);
plot(ax1, 1:5, 1:5);
ax2 = subplot(1, 2, 2);
plot(ax2, 1:5, (1:5).^2);
title(ax1, 'Linear');
title(ax2, 'Quadratic');

Expected output:

% Titles are attached to their respective axes regardless of which is currently selected

Create a multiline title from a string array

plot(1:5, [2 4 1 3 5]);
title(["Top line"; "Bottom line"]);

Expected output:

% Both strings appear, stacked above the axes

Update a title after plotting using set

plot(1:10, rand(1, 10));
h = title('Draft');
set(h, 'String', 'Final Title', 'FontSize', 14);

Expected output:

% The axes title is updated in place

FAQ

How is title different from sgtitle?

title is axes-scoped: it attaches to one panel. sgtitle is figure-scoped and is drawn once above all subplot panels. Use title for per-panel labels and sgtitle for an overall figure heading.

How do I create a multiline title?

Pass a string array or cell array. RunMat joins the elements with newlines.

title({'First line', 'Second line'});
Can I update the title after the plot is created?

Yes. title returns a text handle, so you can update it at any time with set.

h = title('Initial');
set(h, 'String', 'Updated', 'Color', 'r');
How do I set titles on specific subplots without changing the active axes?

Pass the axes handle returned by subplot or gca as the first argument.

ax = subplot(2, 1, 1);
title(ax, 'Top Panel');

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contourf · mesh · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

cla · clf · figure · hold · xline · yline

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how title works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat for free

Write code or describe what you want to compute. The sandbox is free, no account required.