sgtitle

Adds one title above a grid of subplots.

Category: Graphics > Formatting and Annotation

Syntax

sgtitle(txt)

Puts txt as the title of the whole figure.

sgtitle(txt, Name, Value)

Sets text properties such as 'FontSize' or 'Color'.

sgtitle(target, ___)

Places the title in a specific figure or panel.

t = sgtitle(___)

Returns the title object.

Description

Each axes made with subplot has its own title. sgtitle is the "super title" centered above all of them. For a layout made with tiledlayout, the equivalent is title(t, txt) on the layout object.

Input arguments

txt
Title as text, a string array or a cell array of lines.

Output arguments

t
Text object of the title.

Example

Two subplots and a common title

x = 0:0.1:6;
subplot(1, 2, 1), plot(x, sin(x)), title('sin')
subplot(1, 2, 2), plot(x, cos(x)), title('cos')
sgtitle('Trigonometric functions')

In the app, the figure is drawn below the code.

See also

subplot title tiledlayout xlabel text