Discussion:
Subplots with one title
(too old to reply)
Hannes Bauer
2009-02-13 08:15:21 UTC
Permalink
Hello!

Is it possible to make a figure consisting of subplots with one title on top of all subplots instead of one title for each subplot?

Regards,
Dave Brackett
2009-02-13 09:53:01 UTC
Permalink
Post by Hannes Bauer
Hello!
Is it possible to make a figure consisting of subplots with one title on top of all subplots instead of one title for each subplot?
Regards,
just title the top subplot, e.g.

figure
a=subplot(2,1,1)
b=subplot(2,1,2)
title(a,'title')
DanF211
2009-02-13 10:50:03 UTC
Permalink
Post by Dave Brackett
Post by Hannes Bauer
Hello!
Is it possible to make a figure consisting of subplots with one title on top of all subplots instead of one title for each subplot?
Regards,
just title the top subplot, e.g.
figure
a=subplot(2,1,1)
b=subplot(2,1,2)
title(a,'title')
That doesn't really work if there are four subplots because the title will be above the first one, i.e. on the left. It would be nice to have a way of putting the title at the top centre of the figure, regardless of the number/configuration of subplots.
Dave Brackett
2009-02-13 11:26:02 UTC
Permalink
Post by DanF211
Post by Dave Brackett
Post by Hannes Bauer
Hello!
Is it possible to make a figure consisting of subplots with one title on top of all subplots instead of one title for each subplot?
Regards,
just title the top subplot, e.g.
figure
a=subplot(2,1,1)
b=subplot(2,1,2)
title(a,'title')
That doesn't really work if there are four subplots because the title will be above the first one, i.e. on the left. It would be nice to have a way of putting the title at the top centre of the figure, regardless of the number/configuration of subplots.
ok, you could use text(x,y,'string') to create a text string on the figure. just would need to get the x and y coordinates for positioning. You could link the x coordinates to the size of the figure window so that it is always in the middle.
Dave Brackett
2009-02-13 11:36:01 UTC
Permalink
Post by Dave Brackett
Post by DanF211
Post by Dave Brackett
Post by Hannes Bauer
Hello!
Is it possible to make a figure consisting of subplots with one title on top of all subplots instead of one title for each subplot?
Regards,
just title the top subplot, e.g.
figure
a=subplot(2,1,1)
b=subplot(2,1,2)
title(a,'title')
That doesn't really work if there are four subplots because the title will be above the first one, i.e. on the left. It would be nice to have a way of putting the title at the top centre of the figure, regardless of the number/configuration of subplots.
ok, you could use text(x,y,'string') to create a text string on the figure. just would need to get the x and y coordinates for positioning. You could link the x coordinates to the size of the figure window so that it is always in the middle.
actually, scrub that last comment, you can't use that as that only puts text within an axes, and while you could create an invisible axes the same size as the figure, it would probably be a bit of a pain.

however, there is this function on the file exchange called supertitle which should do what you want: http://www.mathworks.com/matlabcentral/fileexchange/3233
Adam A
2010-03-11 13:58:25 UTC
Permalink
Post by Dave Brackett
however, there is this function on the file exchange called supertitle which should do what you want: http://www.mathworks.com/matlabcentral/fileexchange/3233
The function 'supertitle' doesn't seem to exist in the file exchange any more.

However, the function 'mtit' does the job quite nicely instead:
http://www.mathworks.com/matlabcentral/fileexchange/3218-mtit-a-pedestrian-major-title-creator
Arseny
2011-07-20 00:30:19 UTC
Permalink
If the subplots don't have titles of their own, this simple code seems to work:

set(gcf,'NextPlot','add');
axes;
h = title('MyTitle');
set(gca,'Visible','off');
set(h,'Visible','on');
Paw
2013-03-13 12:40:07 UTC
Permalink
Post by Arseny
set(gcf,'NextPlot','add');
axes;
h = title('MyTitle');
set(gca,'Visible','off');
set(h,'Visible','on');
Worked like a charm. Thanks.
Mircea
2013-06-05 14:59:09 UTC
Permalink
If your subplots have titles, you could try
suptitle, instead title

doc suptitle for details
Erol
2013-06-10 11:56:08 UTC
Permalink
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
Yes - that's a handy command right there.
Trevor
2014-02-06 21:45:11 UTC
Permalink
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
suptitle for the win! Definitely what I was looking for to easily add a title to a 2x2 subplot, thanks!
Giovanni de amici
2014-05-19 17:07:13 UTC
Permalink
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
my installation of Matlab (r2013b, 8.2.0.701 on a mac) does not know what 'suptitle' is.
does that command come with one of the additional toolboxes?
dpb
2014-05-19 17:15:56 UTC
Permalink
Post by Giovanni de amici
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
my installation of Matlab (r2013b, 8.2.0.701 on a mac) does not know what 'suptitle' is.
does that command come with one of the additional toolboxes?
Don't know it, either...there's _suplabel_ submission on the File
Exchange...maybe it's what the other respondent's thinking of.

<http://www.mathworks.com/matlabcentral/fileexchange/7772-suplabel>

--
Omar Mian
2014-05-22 22:33:08 UTC
Permalink
Post by Giovanni de amici
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
my installation of Matlab (r2013b, 8.2.0.701 on a mac) does not know what 'suptitle' is.
does that command come with one of the additional toolboxes?
I find suptitle.m here: C:\Program Files (x86)\MATLAB\R2012b\toolbox\bioinfo\biodemos\
I'm assuming this is the bioinformatics toolbox.
dpb
2014-05-22 22:43:25 UTC
Permalink
Post by Omar Mian
Post by Giovanni de amici
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
Post by Mircea
doc suptitle for details
my installation of Matlab (r2013b, 8.2.0.701 on a mac) does not know what 'suptitle' is.
does that command come with one of the additional toolboxes?
I find suptitle.m here: C:\Program Files
(x86)\MATLAB\R2012b\toolbox\bioinfo\biodemos\
I'm assuming this is the bioinformatics toolbox.
Ayup, that it is...interesting place to find such a likely useful tool.
Who can explain the myriad mysteries of TMW and Matlab bundling???

--
May-Linn
2015-01-11 08:06:15 UTC
Permalink
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
Hi,
I just used the 'suptitle' for my 4x4 subplot, but it seems to re-size the first row of sub plots in such a way that the first one is very small, the two next increasingly bigger while the last subplot on first row is regular size. The other rows are unaffected.
Anyone familiar with this?
Swati Soni
2015-02-20 11:34:02 UTC
Permalink
Post by May-Linn
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
Hi,
I just used the 'suptitle' for my 4x4 subplot, but it seems to re-size the first row of sub plots in such a way that the first one is very small, the two next increasingly bigger while the last subplot on first row is regular size. The other rows are unaffected.
Anyone familiar with this?
Hi May-Linn,

I used suptitle('My title') and it works perfect.
I plotted 2 rows and 3 columns of subplots and it was fine. I didn't get the problem you mentioned.
Nantachai
2015-03-04 21:11:41 UTC
Permalink
Post by May-Linn
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
Hi,
I just used the 'suptitle' for my 4x4 subplot, but it seems to re-size the first row of sub plots in such a way that the first one is very small, the two next increasingly bigger while the last subplot on first row is regular size. The other rows are unaffected.
Anyone familiar with this?
Hi May Linn,

I experienced the same problem. I believe you have suptitle in a loop you use subplot command. I get rid of this by having the 'suptitle' outside of the loop. This should work
Eduardo Zanella de Arruda
2016-06-29 23:02:03 UTC
Permalink
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
Thats exacly what he was asking for, nice one, Thank you!
shir shalom
2016-09-01 10:19:03 UTC
Permalink
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
Oh my god thank you for that.
Vishnu Nair
2017-06-25 18:19:05 UTC
Permalink
Post by Mircea
If your subplots have titles, you could try
suptitle, instead title
doc suptitle for details
That's the right answer.

Jakob
2016-08-16 16:52:03 UTC
Permalink
Post by Paw
Post by Arseny
set(gcf,'NextPlot','add');
axes;
h = title('MyTitle');
set(gca,'Visible','off');
set(h,'Visible','on');
Worked like a charm. Thanks.
It does work and it looks nice.
But I found that it has a disadvantage: since another axes lies on top of the axes that contains your actual graphs, you cannot manipulate (e.g. zoom or pan) your graphs.
I tried to produce the title first and put the axes with the graphs on top of that but it covered the title. Probably would have to set the axes color (didn't take the time to try).

Thanks anyway for the trick ;-)
Loading...