MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

New to MATLAB?

# Thread Subject: Subplots with one title

Subject: Subplots with one title

From: Hannes Bauer

### Hannes Bauer (view profile)

Date: 13 Feb, 2009 08:15:21

Message: 1 of 18

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,

Subject: Subplots with one title

From: Dave Brackett

### Dave B (view profile)

(Dave Brackett)

Date: 13 Feb, 2009 09:53:01

Message: 2 of 18

"Hannes Bauer" <pixstamp@gmx.net> wrote in message <gn3a6p\$juk\$1@fred.mathworks.com>...
> 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')

Subject: Subplots with one title

From: DanF211

### DanF211 (view profile)

Date: 13 Feb, 2009 10:50:03

Message: 3 of 18

"Dave Brackett" <davebrackett@hotmail.com> wrote in message <gn3ftt\$bh0\$1@fred.mathworks.com>...
> "Hannes Bauer" <pixstamp@gmx.net> wrote in message <gn3a6p\$juk\$1@fred.mathworks.com>...
> > 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.

Subject: Subplots with one title

From: Dave Brackett

### Dave B (view profile)

(Dave Brackett)

Date: 13 Feb, 2009 11:26:02

Message: 4 of 18

"DanF211 " <daniel.cromb@iop.kcl.ac.uk> wrote in message <gn3j8r\$qdg\$1@fred.mathworks.com>...
> "Dave Brackett" <davebrackett@hotmail.com> wrote in message <gn3ftt\$bh0\$1@fred.mathworks.com>...
> > "Hannes Bauer" <pixstamp@gmx.net> wrote in message <gn3a6p\$juk\$1@fred.mathworks.com>...
> > > 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.

Subject: Subplots with one title

From: Dave Brackett

### Dave B (view profile)

(Dave Brackett)

Date: 13 Feb, 2009 11:36:01

Message: 5 of 18

"Dave Brackett" <davebrackett@hotmail.com> wrote in message <gn3lc9\$j8g\$1@fred.mathworks.com>...
> "DanF211 " <daniel.cromb@iop.kcl.ac.uk> wrote in message <gn3j8r\$qdg\$1@fred.mathworks.com>...
> > "Dave Brackett" <davebrackett@hotmail.com> wrote in message <gn3ftt\$bh0\$1@fred.mathworks.com>...
> > > "Hannes Bauer" <pixstamp@gmx.net> wrote in message <gn3a6p\$juk\$1@fred.mathworks.com>...
> > > > 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

Subject: Subplots with one title

Date: 11 Mar, 2010 13:58:25

Message: 6 of 18

> 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

Subject: Subplots with one title

From: Arseny

### Arseny (view profile)

Date: 20 Jul, 2011 00:30:19

Message: 7 of 18

If the subplots don't have titles of their own, this simple code seems to work:

axes;
h = title('MyTitle');
set(gca,'Visible','off');
set(h,'Visible','on');

Subject: Subplots with one title

From: Paw

### Paw (view profile)

Date: 13 Mar, 2013 12:40:07

Message: 8 of 18

> axes;
> h = title('MyTitle');
> set(gca,'Visible','off');
> set(h,'Visible','on');

Worked like a charm. Thanks.

Subject: Subplots with one title

From: Mircea

### Mircea (view profile)

Date: 5 Jun, 2013 14:59:09

Message: 9 of 18

If your subplots have titles, you could try

doc suptitle for details

Subject: Subplots with one title

From: Erol

### Erol (view profile)

Date: 10 Jun, 2013 11:56:08

Message: 10 of 18

"Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
> If your subplots have titles, you could try
>
> doc suptitle for details

Yes - that's a handy command right there.

Subject: Subplots with one title

From: Trevor

### Trevor (view profile)

Date: 6 Feb, 2014 21:45:11

Message: 11 of 18

"Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
> If your subplots have titles, you could try
>
> doc suptitle for details

suptitle for the win! Definitely what I was looking for to easily add a title to a 2x2 subplot, thanks!

Subject: Subplots with one title

From: Giovanni de amici

### Giovanni de amici (view profile)

Date: 19 May, 2014 17:07:13

Message: 12 of 18

"Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
> If your subplots have titles, you could try
>
> 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?

Subject: Subplots with one title

From: dpb

### dpb (view profile)

Date: 19 May, 2014 17:15:56

Message: 13 of 18

On 5/19/2014 12:07 PM, Giovanni de amici wrote:
> "Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
>> If your subplots have titles, you could try
>>
>> 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>

--

Subject: Subplots with one title

From: Omar Mian

### Omar Mian (view profile)

Date: 22 May, 2014 22:33:08

Message: 14 of 18

"Giovanni de amici" <giovanniremove.thisdeamicireplace@thatnasa.gov> wrote in message <llddo0\$cg8\$1@newscl01ah.mathworks.com>...
> "Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
> > If your subplots have titles, you could try
> >
> > 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.

Subject: Subplots with one title

From: dpb

### dpb (view profile)

Date: 22 May, 2014 22:43:25

Message: 15 of 18

On 5/22/2014 5:33 PM, Omar Mian wrote:
> "Giovanni de amici" <giovanniremove.thisdeamicireplace@thatnasa.gov>
> wrote in message <llddo0\$cg8\$1@newscl01ah.mathworks.com>...
>> "Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
>> > If your subplots have titles, you could try
>> > > 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???

--

Subject: Subplots with one title

From: May-Linn

### May-Linn (view profile)

Date: 11 Jan, 2015 08:06:15

Message: 16 of 18

"Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
> If your subplots have titles, you could try
>
> 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?

Subject: Subplots with one title

From: Swati Soni

### Swati Soni (view profile)

Date: 20 Feb, 2015 11:34:02

Message: 17 of 18

"May-Linn " <marinebiogeochemistry@gmail.com> wrote in message <m8tatn\$pri\$1@newscl01ah.mathworks.com>...
> "Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
> > If your subplots have titles, you could try
> >
> > 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.

Subject: Subplots with one title

From: Nantachai

### Nantachai (view profile)

Date: 4 Mar, 2015 21:11:41

Message: 18 of 18

"May-Linn " <marinebiogeochemistry@gmail.com> wrote in message <m8tatn\$pri\$1@newscl01ah.mathworks.com>...
> "Mircea" wrote in message <konjnt\$mfp\$1@newscl01ah.mathworks.com>...
> > If your subplots have titles, you could try
> >
> > 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