sgtitle — Set a title centered above the entire figure, especially for multi-subplot layouts.
sgtitle sets or updates a figure-level title that is rendered once above the full figure rather than attached to a single axes. In RunMat phase 1, it targets the current figure by default or an explicit figure handle when one is passed, returns a text handle, participates in get and set, and persists through scene replay and export.
How sgtitle works
- The returned value is a text handle that can be inspected or updated through
getandset. - Unlike
title,sgtitleis figure-scoped and is drawn once above all subplot panels. - String scalars, char arrays, string arrays, and cell arrays can all be used to create multiline super titles.
- Text styling properties such as
FontSize,FontWeight,FontAngle,Color,Interpreter, andVisibleuse the shared plotting text-property system.
Examples
Add a super title above a subplot figure
subplot(2, 2, 1);
plot(1:10, rand(1, 10));
subplot(2, 2, 2);
plot(1:10, rand(1, 10));
subplot(2, 2, 3);
plot(1:10, rand(1, 10));
subplot(2, 2, 4);
plot(1:10, rand(1, 10));
sgtitle('Experiment Summary');Style the figure-level title and inspect the returned handle
subplot(1, 2, 1);
imagesc(peaks(20));
subplot(1, 2, 2);
imagesc(peaks(20));
h = sgtitle('Field Comparison', 'FontSize', 18, 'FontWeight', 'bold');
get(h, 'Type')Expected output:
ans =
'text'Target an explicit figure handle
fig = figure(42);
subplot(1, 2, 1);
plot(0:0.1:1, sin(0:0.1:1));
subplot(1, 2, 2);
plot(0:0.1:1, cos(0:0.1:1));
sgtitle(fig, 'Sine and Cosine');FAQ
How is sgtitle different from title?
title attaches text to the current axes, so each subplot can have its own panel title. sgtitle attaches text to the figure as a whole and is drawn once above all panels. Use title for per-panel labels and sgtitle for the overall figure heading.
Can I update the super title after creating it?
Yes. sgtitle returns a text handle, so you can inspect or update it with get and set.
h = sgtitle('Initial Title');
set(h, 'String', 'Updated Title', 'FontWeight', 'bold');What target objects are supported?
Phase 1 supports the current figure by default and explicit figure handles through sgtitle(fig, txt, ...). Larger MATLAB target containers such as panels or tabs are tracked separately and are not part of the current implementation.
Related functions to explore
These functions work well alongside sgtitle. Each page has runnable examples you can try in the browser.
title, subplot, figure, get, set
More plotting resources
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how sgtitle works, line by line, in Rust.
- View sgtitle.rs on GitHub
- Learn how the 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 — 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.