MATLAB Answers

Mr M.
0

is it possible to define global title on figures?

Asked by Mr M.
on 15 Apr 2015
Latest activity Answered by Paul Huxel on 9 Oct 2018
I have subplots with titles, but I want to add a title to the whole figure. Is it possible?

  0 Comments

Sign in to comment.

4 Answers

Answer by Paul Huxel on 9 Oct 2018
 Accepted Answer

Starting in R2018b, you can use sgtitle to add a title to subplot grids:

  0 Comments

Sign in to comment.


Answer by Brendan Hamm on 15 Apr 2015

Yes this is possible by creating a new axes which takes up much of the figure. Then a title for this axes. Turning the axes Visible property 'off' will make the axes "disappear", but the title will inherit this property and you will need to turn the Visible property for the title back 'on'.
x = 0:0.001:2*pi;
y1 = cos(x);
y2 = sin(x);
f = figure;
subplot(2,1,1)
plot(x,y1)
subplot(2,1,2)
plot(x,y2)
a = axes;
t1 = title('Global Title');
a.Visible = 'off'; % set(a,'Visible','off');
t1.Visible = 'on'; % set(t1,'Visible','on');
Note: In prior versions you may need to use the set command as done in the comments
You may need to tweak the Position property of the axes, a, so the titles do not overlap.

  1 Comment

More generally useful; I used it to put a text label on pages containing a variable number of subplots, where I needed the text to appear at the same place on all pages.

Sign in to comment.


Answer by Sean de Wolski
on 16 Jul 2015

If you have the Bioinformatics Toolbox you can also use suptitle.
suptitle('I''m a Super Title')

  0 Comments

Sign in to comment.


Answer by Steven Lord
on 16 Jul 2015

Do you need a title for printing/exporting purposes or do you need a title in order to distinguish between multiple figures created by the code you're executing? In the latter case another alternative is to set the Name property of the figure.
f = figure;
f.Name = 'First figure';

  0 Comments

Sign in to comment.