- 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,901 ビュー (過去 30 日間)
MathWorks Support Team 2022 年 8 月 1 日
編集済み: MathWorks Support Team 2022 年 8 月 3 日
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:
その他の回答 (10 件)
jcjaimes 2016 年 12 月 15 日
Suptitle does the job
suptitle('I am a super title')
Paul Huxel 2018 年 10 月 9 日
Jonathan Beard 2017 年 5 月 9 日
Here's a solution that doesn't require additional functions.
subplot(2, 1, 1);
subplot(2, 1, 2);
currentFigure = gcf;
Bradley Stiritz 2018 年 9 月 9 日
>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 2020 年 12 月 9 日
編集済み: Eric Sargent 2020 年 12 月 9 日
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 2017 年 10 月 31 日
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 2019 年 7 月 4 日
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.