How can I insert a title over a group of subplots?

5.024 visualizaciones (últimos 30 días)
I would like to place a title over a group of subplots. How can I do this?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 8 de Dic. de 2023
Editada: MathWorks Support Team el 14 de Dic. de 2023
Starting in R2019b, you can use the tiledlayout and nexttile functions to create a configurable tiling of plots. The configuration options include: 
  • 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 
An example of 'tiledlayout' used to create a 2x2 group of subplots is written below:
tcl = tiledlayout(2,2);
title('First Subplot')
title('Second Subplot')
title('Third Subplot')
title('Fourth Subplot')
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: 
title('First Subplot') 
title('Second Subplot') 
title('Third Subplot') 
title('Fourth Subplot') 
sgtitle('Subplot Grid Title') 
For more information on the 'sgtitle' function, see
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 more information, 
  4 comentarios
Walter Roberson
Walter Roberson el 18 de Jun. de 2018
suptitle() is part of the Bioinformatics toolbox.
madhan ravi
madhan ravi el 16 de Oct. de 2018
Editada: Walter Roberson el 16 de Oct. de 2018
There’s a new feature in 2018b which makes it possible

Iniciar sesión para comentar.

Más respuestas (5)

jcjaimes el 15 de Dic. de 2016
Suptitle does the job
subplot(2,2,1); plot(sin(x))
subplot(2,2,2); plot(cos(x))
subplot(2,2,3); plot(cos(x.^2))
subplot(2,2,4); plot(sin(x.^2))
suptitle('I am a super title')

Paul Huxel
Paul Huxel el 9 de Oct. de 2018
Starting in R2018b, you can use sgtitle to add a title to subplot grids:

Bradley Stiritz
Bradley Stiritz el 9 de Sept. de 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.
  2 comentarios
ANKUR KUMAR el 10 de Sept. de 2018
There is a function suptitle which may does our work. It puts perfectly the title over all subplots.
Cris LaPierre
Cris LaPierre el 25 de Oct. de 2018
FYI: suptitle is only available to those who have the Bioinformatics toolbox, and then it was included in a demo file and is not an actual MathWorks maintained function.
However, as Paul Huxel points out, there is now (r2018b) a function in base MATLAB for this. It is called sgtitle.

Iniciar sesión para comentar.

Eric Sargent
Eric Sargent el 9 de Dic. de 2020
Editada: Eric Sargent el 9 de Dic. de 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
title(tl,'Layout Title');
xlabel(tl,'Layout XLabel');
ylabel(tl,'Layout YLabel');

Gouater Loic
Gouater Loic el 6 de Oct. de 2020
This video clearly explains that


Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by