Main Content


Add title to subplot grid



sgtitle(txt) adds a title above the grid of subplots in the current figure. If a figure does not it exist, then this command creates one.

sgtitle(target,txt) adds the title to the subplot grid in the specified figure, panel, or tab, instead of the current figure.

sgtitle(___,Name,Value) modifies text properties using one or more name-value pair arguments. For example, 'FontSize',12 specifies 12-point font. For a list of properties, see Text Properties. Specify name-value pair arguments after all the other input arguments.

sgt = sgtitle(___) returns the subplot Text object used to create the title.


collapse all

Create a figure with four subplots. Add a title to each subplot, and then add an overall title to the subplot grid.

title('First Subplot')
title('Second Subplot')
title('Third Subplot')
title('Fourth Subplot')

sgtitle('Subplot Grid Title')

Modify a title appearance by setting properties, first by using name-value pair arguments, and then by returning the Text object created and using dot notation.

Change the Color property using a name-value pair argument. Next, change the FontSize property using dot notation.

title('First Subplot')
title('Second Subplot')

sgt = sgtitle('Subplot Grid Title','Color','red');
sgt.FontSize = 20;

Input Arguments

collapse all

Text to display, specified as a character vector, cell array of character vectors, string array, or numeric value.

Example: 'my label'

Example: {'first line','second line'}

Example: string('my label')

Example: 123

To include numeric variables with text, use the num2str function. For example:

x = 42;
txt = ['The value is ',num2str(x)];

To include special characters, such as superscripts, subscripts, Greek letters, or mathematical symbols use TeX markup. For a list of supported markup, see the Interpreter property of the Text object.

To create multiline text, use these conventions:

  • Use a cell array, where each cell contains a line of text, such as {'first line','second line'}.

  • Use a string array, where each element contains a line of text, such as string({'line one','line two'}).

  • Use a character array, where each row contains the same number of characters, such as ['abc'; 'ab '].

  • Use sprintf to create text with a new line character, such as sprintf('first line \n second line'). This property converts text with new line characters to cell arrays.

If the text contains only a numeric value, then it is converted using sprintf('%g',value). For example, 12345678 displays as 1.23457e+07.

Subplot grid container, specified as a Figure, Panel, or Tab object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: sgtitle('My Title','FontSize',14)


The properties listed here are only a subset. For a full list, see Text Properties.

Font size, specified as a scalar value greater than zero in point units. The default font size depends on the specific operating system and locale. One point equals 1/72 inch. To change the font units, use the FontUnits property.

Example: 12

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Font name, specified as a supported font name or 'FixedWidth'. To display and print text properly, you must choose a font that your system supports. The default font depends on your operating system and locale.

To use a fixed-width font that looks good in any locale, use 'FixedWidth'. The fixed-width font relies on the root FixedWidthFontName property. Setting the root FixedWidthFontName property causes an immediate update of the display to use the new font.

Version History

Introduced in R2018b

See Also