- Control over the spacing between the plots and around the edges of the layout
- An option for a shared title at the top of the layout
- Options for shared x- and y-axis labels
- An option to control whether the tiling has a fixed size or variable size that can reflow
How can I insert a title over a group of subplots?
6,885 views (last 30 days)
MathWorks Support Team on 1 Aug 2022
Edited: MathWorks Support Team on 3 Aug 2022
Starting in R2019b, you can use the tiledlayout and nexttile functions to create a configurable tiling of plots. The configuration options include:
An example of 'tiledlayout' used to create a 2x2 group of subplots is written below:
tcl = tiledlayout(2,2);
title(tcl,'Subplot Grid Title')
For more information, see Combine Multiple Plots.
Starting in R2018b, you can use the 'sgtitle' function to add a title to a group of subplots. For example:
sgtitle('Subplot Grid Title')
For more information on the 'sgtitle' function, see https://www.mathworks.com/help/matlab/ref/sgtitle.html.
In previous releases (before R2018b), you can create the appearance of a super title by creating the subplots in a panel and adding a title to the panel. For an example, see:
More Answers (10)
jcjaimes on 15 Dec 2016
Suptitle does the job
suptitle('I am a super title')
Paul Huxel on 9 Oct 2018
Jonathan Beard on 9 May 2017
Here's a solution that doesn't require additional functions.
subplot(2, 1, 1);
subplot(2, 1, 2);
currentFigure = gcf;
Bradley Stiritz on 9 Sep 2018
>Answer by MathWorks Support Team on 26 Apr 2010
>It is not possible to put a title over a group of subplots in MATLAB..
With respect, this is not a helpful comment, as it's apparently not true. It is possible, just not with built-in core Matlab functionality. Most people will hopefully continue reading the thread, and learn about the workarounds. Still, it's not an encouraging or precise statement to begin the group discussion, IMHO.
Eric Sargent on 9 Dec 2020
Edited: Eric Sargent on 9 Dec 2020
Starting in R2019b, you can also use tiledlayout and nexttile instead of subplot, which has shared titles and labels. You can use the title, xlabel, and ylabel commands directly with tiledlayouts:
Alternatively, starting in R2018b, the sgtitle function will add a title over a group of subplots.
tl = tiledlayout(3,3);
for i = 1:9
Dan on 31 Oct 2017
Thanks! This works great. I set did >set(h,'Position',[.5 1.05 .5]) to get place the supertitle above the titles of my subplots.
JB on 4 Jul 2019
A great big thank you to the writer of mtit! That worked great for me, being someone who is between 2018 and the version I originally wrote my code in where my title for the subplot was centered without having to do anything extra.