Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Subplot matrix: remove dead space between plots

Subject: Subplot matrix: remove dead space between plots

From: Jim Rockford

Date: 29 May, 2007 00:14:28

Message: 1 of 12

I have a 4x4 array of subplots that I'd like to make closer together
(i.e. eliminate dead space/gray space). The code that generates the
figure is

***********************************************
figure;
fig = gcf;
for index=1:16
  pHandles(index)=subplot(4,4,index);
  colormap(mycolormap); % 64x3 colormap
  image(zeros(16,16)+33); % Each image is a 16x16 matrix
  axis('square'); axis off;
end
set(fig,'DoubleBuffer','on');
***********************************************

Note: I initialize each subplot figure with a blank image, each of
which will be updated
  as I collect data for my purposes.

There is quite a bit of dead space between the individual plots. Is
there a reasonably simple way to control the size of each square? I'm
looking for a single control parameter that I can tweak until I like
the sizing. I'm running Matlab 7.1 (sp3).

Thanks,
Jim

Subject: Subplot matrix: remove dead space between plot

From: Peter Bone

Date: 29 May, 2007 06:09:38

Message: 2 of 12

Jim Rockford wrote:
>
>
> I have a 4x4 array of subplots that I'd like to make closer
> together
> (i.e. eliminate dead space/gray space). The code that generates
> the
> figure is
>
> ***********************************************
> figure;
> fig = gcf;
> for index=1:16
> pHandles(index)=subplot(4,4,index);
> colormap(mycolormap); % 64x3 colormap
> image(zeros(16,16)+33); % Each image is a 16x16 matrix
> axis('square'); axis off;
> end
> set(fig,'DoubleBuffer','on');
> ***********************************************
>
> Note: I initialize each subplot figure with a blank image, each of
> which will be updated
> as I collect data for my purposes.
>
> There is quite a bit of dead space between the individual plots.
> Is
> there a reasonably simple way to control the size of each square?
> I'm
> looking for a single control parameter that I can tweak until I
> like
> the sizing. I'm running Matlab 7.1 (sp3).
>
> Thanks,
> Jim

This will remove all white space. Play around with the values to give
the right amount.

set(gca,'Position',[0 0 1 1])

Subject: Subplot matrix: remove dead space between plot

From: Jim Rockford

Date: 29 May, 2007 23:22:35

Message: 3 of 12

On May 29, 6:09 am, "Peter Bone" <peterb...@hotmail.com> wrote:
> This will remove all white space. Play around with the values to give
> the right amount.
>
> set(gca,'Position',[0 0 1 1])

Thanks, but this doesn't quite do what I want. It did lead me in the
right direction though. It seems there is no easy, one-line
adjustment to "fatten up" the subplot windows. For each subplot I
used

handle(index) = subplot('Position',[left(index) bottom(index) width
height])

where I had to pre-define left(index) and bottom(index) for each of
the subplots. Pretty tedious stuff, but it works. Matlab really
could use a more convenient graphical interface for this purpose.

Jim

Subject: Subplot matrix: remove dead space between plot

From: Steven Lord

Date: 30 May, 2007 10:00:52

Message: 4 of 12


"Jim Rockford" <jim.rockford1@gmail.com> wrote in message
news:1180506155.100697.253990@q75g2000hsh.googlegroups.com...
> On May 29, 6:09 am, "Peter Bone" <peterb...@hotmail.com> wrote:
>> This will remove all white space. Play around with the values to give
>> the right amount.
>>
>> set(gca,'Position',[0 0 1 1])
>
> Thanks, but this doesn't quite do what I want. It did lead me in the
> right direction though. It seems there is no easy, one-line
> adjustment to "fatten up" the subplot windows. For each subplot I
> used
>
> handle(index) = subplot('Position',[left(index) bottom(index) width
> height])
>
> where I had to pre-define left(index) and bottom(index) for each of
> the subplots. Pretty tedious stuff, but it works. Matlab really
> could use a more convenient graphical interface for this purpose.

You can do what you want through the figure's regular interface. Create a
set of subplot axes:


subplot(2,1,2); surf(peaks); subplot(2,1,1); plot(1:10)


Click on the arrow (Edit Plot) between the Print button (the button with a
printer as the icon) and the Zoom In button (whose icon is a magnifying
glass with a + symbol in it) in the figure toolbar.

Click on the axes whose position you want to adjust, then drag the corners
or sides of that axes by clicking on the selection handles.

Once you've set up the layout the way you want, if you want to use that
layout for more figures, go to the File menu and select "Generate M-File".
You can then use the generated M-file on its own, or pull out the
appropriate pieces and copy them into your program. You can also save the
figure as a FIG file and reopen it with OPENFIG when you want to use it
later.

--
Steve Lord
slord@mathworks.com

Subject: Subplot matrix: remove dead space between plot

From: Seth

Date: 7 Jun, 2011 01:14:04

Message: 5 of 12

"Steven Lord" <slord@mathworks.com> wrote in message <f3k02k$n6s$1@fred.mathworks.com>...
>
> "Jim Rockford" <jim.rockford1@gmail.com> wrote in message
> news:1180506155.100697.253990@q75g2000hsh.googlegroups.com...
> > On May 29, 6:09 am, "Peter Bone" <peterb...@hotmail.com> wrote:
> >> This will remove all white space. Play around with the values to give
> >> the right amount.
> >>
> >> set(gca,'Position',[0 0 1 1])
> >
> > Thanks, but this doesn't quite do what I want. It did lead me in the
> > right direction though. It seems there is no easy, one-line
> > adjustment to "fatten up" the subplot windows. For each subplot I
> > used
> >
> > handle(index) = subplot('Position',[left(index) bottom(index) width
> > height])
> >
> > where I had to pre-define left(index) and bottom(index) for each of
> > the subplots. Pretty tedious stuff, but it works. Matlab really
> > could use a more convenient graphical interface for this purpose.
>
> You can do what you want through the figure's regular interface. Create a
> set of subplot axes:
>
>
> subplot(2,1,2); surf(peaks); subplot(2,1,1); plot(1:10)
>
>
> Click on the arrow (Edit Plot) between the Print button (the button with a
> printer as the icon) and the Zoom In button (whose icon is a magnifying
> glass with a + symbol in it) in the figure toolbar.
>
> Click on the axes whose position you want to adjust, then drag the corners
> or sides of that axes by clicking on the selection handles.
>
> Once you've set up the layout the way you want, if you want to use that
> layout for more figures, go to the File menu and select "Generate M-File".
> You can then use the generated M-file on its own, or pull out the
> appropriate pieces and copy them into your program. You can also save the
> figure as a FIG file and reopen it with OPENFIG when you want to use it
> later.
>
> --
> Steve Lord
> slord@mathworks.com
>
>

I think what would be really nice is if Matlab didn't put so much default white space in between subplots. Steve's solution works, but you have to go in and edit by hand. This is incredibly annoying and time consuming. Matlab should just default to much, much less white space in between subplots. I am constantly manually editing subplots to decrease the white space. I have so many routines that create figures automatically, I just wish ML would make the default spacing smaller. What is even more annoying, is if you set the x-axis ticks to not display, it has no effect on the amount of white space in between subplots. It just removes the labels without putting the subplots any closer together.

--Seth

Subject: Subplot matrix: remove dead space between plot

From: Steven_Lord

Date: 7 Jun, 2011 03:48:08

Message: 6 of 12



"Seth " <seth.g.claudepierre@aero.org> wrote in message
news:isju0s$6dp$1@newscl01ah.mathworks.com...
> "Steven Lord" <slord@mathworks.com> wrote in message
> <f3k02k$n6s$1@fred.mathworks.com>...

*snip*

> I think what would be really nice is if Matlab didn't put so much default
> white space in between subplots. Steve's solution works, but you have to
> go in and edit by hand. This is incredibly annoying and time consuming.
> Matlab should just default to much, much less white space in between
> subplots. I am constantly manually editing subplots to decrease the white
> space. I have so many routines that create figures automatically, I just
> wish ML would make the default spacing smaller. What is even more
> annoying, is if you set the x-axis ticks to not display, it has no effect
> on the amount of white space in between subplots. It just removes the
> labels without putting the subplots any closer together.

That sounds like a perfectly reasonable enhancement request to submit to
Technical Support. Explain how frequently you need to modify your figures to
reduce the space and explain how much space you include around an axes in
your application.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Subplot matrix: remove dead space between plot

From: Kacey

Date: 11 Aug, 2011 18:24:28

Message: 7 of 12

"Seth" wrote in message <isju0s$6dp$1@newscl01ah.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote in message <f3k02k$n6s$1@fred.mathworks.com>...
> >
> > "Jim Rockford" <jim.rockford1@gmail.com> wrote in message
> > news:1180506155.100697.253990@q75g2000hsh.googlegroups.com...
> > > On May 29, 6:09 am, "Peter Bone" <peterb...@hotmail.com> wrote:
> > >> This will remove all white space. Play around with the values to give
> > >> the right amount.
> > >>
> > >> set(gca,'Position',[0 0 1 1])
> > >
> > > Thanks, but this doesn't quite do what I want. It did lead me in the
> > > right direction though. It seems there is no easy, one-line
> > > adjustment to "fatten up" the subplot windows. For each subplot I
> > > used
> > >
> > > handle(index) = subplot('Position',[left(index) bottom(index) width
> > > height])
> > >
> > > where I had to pre-define left(index) and bottom(index) for each of
> > > the subplots. Pretty tedious stuff, but it works. Matlab really
> > > could use a more convenient graphical interface for this purpose.
> >
> > You can do what you want through the figure's regular interface. Create a
> > set of subplot axes:
> >
> >
> > subplot(2,1,2); surf(peaks); subplot(2,1,1); plot(1:10)
> >
> >
> > Click on the arrow (Edit Plot) between the Print button (the button with a
> > printer as the icon) and the Zoom In button (whose icon is a magnifying
> > glass with a + symbol in it) in the figure toolbar.
> >
> > Click on the axes whose position you want to adjust, then drag the corners
> > or sides of that axes by clicking on the selection handles.
> >
> > Once you've set up the layout the way you want, if you want to use that
> > layout for more figures, go to the File menu and select "Generate M-File".
> > You can then use the generated M-file on its own, or pull out the
> > appropriate pieces and copy them into your program. You can also save the
> > figure as a FIG file and reopen it with OPENFIG when you want to use it
> > later.
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> >
> >
>
> I think what would be really nice is if Matlab didn't put so much default white space in between subplots. Steve's solution works, but you have to go in and edit by hand. This is incredibly annoying and time consuming. Matlab should just default to much, much less white space in between subplots. I am constantly manually editing subplots to decrease the white space. I have so many routines that create figures automatically, I just wish ML would make the default spacing smaller. What is even more annoying, is if you set the x-axis ticks to not display, it has no effect on the amount of white space in between subplots. It just removes the labels without putting the subplots any closer together.
>
> --Seth

Hi there,

I'm just beginning to learn Matlab programming. For viewing my data, I need to create a 16 x 8 array of subplots which I have done. But the catch is modifying and resizing all of the subplots simultaneously with a simple statement. I'm having a hell of a time doing this. I want to designate my own x-axis limits without having to click on every single graph. Also, I'm trying to get rid of the dead space between all 128 of my subplots, which seems from your previous conversations that I have to do that manually anyhow. Do you know how to set the x-axis limits at least without having to modify every subplot in the generated code?

Please let me know if you are able to help me out.

Thanks for your time.

Kacey

Subject: Subplot matrix: remove dead space between plots

From: Christopher Hummersone

Date: 29 Sep, 2011 16:52:28

Message: 8 of 12

Jim (and Kacey, assuming you're using similar code to Jim),

You could just add these lines into your loop (after the line with the AXIS commands):

sub_pos = get(gca,'position'); % get subplot axis position
set(gca,'position',sub_pos.*[1 1 1.2 1.2]) % stretch its width and height

Chris

Jim Rockford <jim.rockford1@gmail.com> wrote in message <1180422868.162937.237240@h2g2000hsg.googlegroups.com>...
> I have a 4x4 array of subplots that I'd like to make closer together
> (i.e. eliminate dead space/gray space). The code that generates the
> figure is
>
> ***********************************************
> figure;
> fig = gcf;
> for index=1:16
> pHandles(index)=subplot(4,4,index);
> colormap(mycolormap); % 64x3 colormap
> image(zeros(16,16)+33); % Each image is a 16x16 matrix
> axis('square'); axis off;
> end
> set(fig,'DoubleBuffer','on');
> ***********************************************
>
> Note: I initialize each subplot figure with a blank image, each of
> which will be updated
> as I collect data for my purposes.
>
> There is quite a bit of dead space between the individual plots. Is
> there a reasonably simple way to control the size of each square? I'm
> looking for a single control parameter that I can tweak until I like
> the sizing. I'm running Matlab 7.1 (sp3).
>
> Thanks,
> Jim
>

Subject: Subplot matrix: remove dead space between plots

From: Aurélien BERTIN

Date: 22 Jun, 2012 13:14:07

Message: 9 of 12

Dear all,

I had the same problem and found a convenient "patch".

I first use instead of simply figure that :
scrsz = get(0,'ScreenSize'); % left, bottom, width, height
figure('position',[1 scrsz(4)/100 scrsz(3)/0.5 scrsz(4)]);

You get there a full screen size figure (useful for the next part).

After, I used Christopher's patch to close the second and the fourth subplot (I have 4 plots) from the first and the third. To do that, after the second and the fourht subplot, I've written:
sub_pos = get(gca,'position'); % get subplot axis position
set(gca,'position',sub_pos.*[0.7 1 1 1]) % stretch its width and height

Note the sub_pos patch only minimize the 'left' component of subplot position, and it's sufficient to close the graphes.

Finally, I use the 'export_fig.m' function, which is amazing, and produces a really nice figure with edges croped. Set the background to 'w', and the image is perfect, as the quality.

Hope it will help! Regards

"Christopher Hummersone" <christopher.hummersone@surrey.ac.uk> wrote in message <j627oc$9oo$1@newscl01ah.mathworks.com>...
> Jim (and Kacey, assuming you're using similar code to Jim),
>
> You could just add these lines into your loop (after the line with the AXIS commands):
>
> sub_pos = get(gca,'position'); % get subplot axis position
> set(gca,'position',sub_pos.*[1 1 1.2 1.2]) % stretch its width and height
>
> Chris
>
> Jim Rockford <jim.rockford1@gmail.com> wrote in message <1180422868.162937.237240@h2g2000hsg.googlegroups.com>...
> > I have a 4x4 array of subplots that I'd like to make closer together
> > (i.e. eliminate dead space/gray space). The code that generates the
> > figure is
> >
> > ***********************************************
> > figure;
> > fig = gcf;
> > for index=1:16
> > pHandles(index)=subplot(4,4,index);
> > colormap(mycolormap); % 64x3 colormap
> > image(zeros(16,16)+33); % Each image is a 16x16 matrix
> > axis('square'); axis off;
> > end
> > set(fig,'DoubleBuffer','on');
> > ***********************************************
> >
> > Note: I initialize each subplot figure with a blank image, each of
> > which will be updated
> > as I collect data for my purposes.
> >
> > There is quite a bit of dead space between the individual plots. Is
> > there a reasonably simple way to control the size of each square? I'm
> > looking for a single control parameter that I can tweak until I like
> > the sizing. I'm running Matlab 7.1 (sp3).
> >
> > Thanks,
> > Jim
> >

Subject: Subplot matrix: remove dead space between plots

From: Christopher Hummersone

Date: 22 Jun, 2012 13:37:05

Message: 10 of 12

To clarify, set the figure colour to 'w' when using export_fig:

set(gcf,'color','w')

If producing publication-quality graphics is the intention, then setting the figure size in this way seems like a bit of a fudge; a quick-and-dirty solution. If you want figures to typeset nicely (with appropriately-sized text) then you should set the figure size accordingly (and use export_fig). For example, if I were publishing a figure that had to fit in a 7" column, then set the figure to be 7 inches wide (and say, 4" tall):

figure('units','inches','position',[6 6 7 4],'color','w')

The set your text to be 9 points, for example:

set(gca,'fontsize',9)

Then when you export (using export_fig) and place the result in your document with 1:1 sizing (taking the DPI into account if using a raster format), you know the figure will be no more than 7" wide, and the text will be 9 points on the page.

Yes, this makes sizing the subplots a bit more tricky, but it removes all of the other guess work that would otherwise be required when producing decent-looking graphics.

Chris

"Aurélien BERTIN" <bertin@ipgp.fr> wrote in message <js1r2v$a8q$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I had the same problem and found a convenient "patch".
>
> I first use instead of simply figure that :
> scrsz = get(0,'ScreenSize'); % left, bottom, width, height
> figure('position',[1 scrsz(4)/100 scrsz(3)/0.5 scrsz(4)]);
>
> You get there a full screen size figure (useful for the next part).
>
> After, I used Christopher's patch to close the second and the fourth subplot (I have 4 plots) from the first and the third. To do that, after the second and the fourht subplot, I've written:
> sub_pos = get(gca,'position'); % get subplot axis position
> set(gca,'position',sub_pos.*[0.7 1 1 1]) % stretch its width and height
>
> Note the sub_pos patch only minimize the 'left' component of subplot position, and it's sufficient to close the graphes.
>
> Finally, I use the 'export_fig.m' function, which is amazing, and produces a really nice figure with edges croped. Set the background to 'w', and the image is perfect, as the quality.
>
> Hope it will help! Regards
>
> "Christopher Hummersone" <christopher.hummersone@surrey.ac.uk> wrote in message <j627oc$9oo$1@newscl01ah.mathworks.com>...
> > Jim (and Kacey, assuming you're using similar code to Jim),
> >
> > You could just add these lines into your loop (after the line with the AXIS commands):
> >
> > sub_pos = get(gca,'position'); % get subplot axis position
> > set(gca,'position',sub_pos.*[1 1 1.2 1.2]) % stretch its width and height
> >
> > Chris
> >
> > Jim Rockford <jim.rockford1@gmail.com> wrote in message <1180422868.162937.237240@h2g2000hsg.googlegroups.com>...
> > > I have a 4x4 array of subplots that I'd like to make closer together
> > > (i.e. eliminate dead space/gray space). The code that generates the
> > > figure is
> > >
> > > ***********************************************
> > > figure;
> > > fig = gcf;
> > > for index=1:16
> > > pHandles(index)=subplot(4,4,index);
> > > colormap(mycolormap); % 64x3 colormap
> > > image(zeros(16,16)+33); % Each image is a 16x16 matrix
> > > axis('square'); axis off;
> > > end
> > > set(fig,'DoubleBuffer','on');
> > > ***********************************************
> > >
> > > Note: I initialize each subplot figure with a blank image, each of
> > > which will be updated
> > > as I collect data for my purposes.
> > >
> > > There is quite a bit of dead space between the individual plots. Is
> > > there a reasonably simple way to control the size of each square? I'm
> > > looking for a single control parameter that I can tweak until I like
> > > the sizing. I'm running Matlab 7.1 (sp3).
> > >
> > > Thanks,
> > > Jim
> > >

Subject: Subplot matrix: remove dead space between plots

From: Aurélien BERTIN

Date: 22 Jun, 2012 14:05:07

Message: 11 of 12

Thanks for the tip!

I was indeed using set(gcf,'Color','w');, I wasn't clear enough!

Regards

"Christopher Hummersone" <christopher.hummersone@surrey.ac.uk> wrote in message <js1se1$ghp$1@newscl01ah.mathworks.com>...
> To clarify, set the figure colour to 'w' when using export_fig:
>
> set(gcf,'color','w')
>
> If producing publication-quality graphics is the intention, then setting the figure size in this way seems like a bit of a fudge; a quick-and-dirty solution. If you want figures to typeset nicely (with appropriately-sized text) then you should set the figure size accordingly (and use export_fig). For example, if I were publishing a figure that had to fit in a 7" column, then set the figure to be 7 inches wide (and say, 4" tall):
>
> figure('units','inches','position',[6 6 7 4],'color','w')
>
> The set your text to be 9 points, for example:
>
> set(gca,'fontsize',9)
>
> Then when you export (using export_fig) and place the result in your document with 1:1 sizing (taking the DPI into account if using a raster format), you know the figure will be no more than 7" wide, and the text will be 9 points on the page.
>
> Yes, this makes sizing the subplots a bit more tricky, but it removes all of the other guess work that would otherwise be required when producing decent-looking graphics.
>
> Chris
>
> "Aurélien BERTIN" <bertin@ipgp.fr> wrote in message <js1r2v$a8q$1@newscl01ah.mathworks.com>...
> > Dear all,
> >
> > I had the same problem and found a convenient "patch".
> >
> > I first use instead of simply figure that :
> > scrsz = get(0,'ScreenSize'); % left, bottom, width, height
> > figure('position',[1 scrsz(4)/100 scrsz(3)/0.5 scrsz(4)]);
> >
> > You get there a full screen size figure (useful for the next part).
> >
> > After, I used Christopher's patch to close the second and the fourth subplot (I have 4 plots) from the first and the third. To do that, after the second and the fourht subplot, I've written:
> > sub_pos = get(gca,'position'); % get subplot axis position
> > set(gca,'position',sub_pos.*[0.7 1 1 1]) % stretch its width and height
> >
> > Note the sub_pos patch only minimize the 'left' component of subplot position, and it's sufficient to close the graphes.
> >
> > Finally, I use the 'export_fig.m' function, which is amazing, and produces a really nice figure with edges croped. Set the background to 'w', and the image is perfect, as the quality.
> >
> > Hope it will help! Regards
> >
> > "Christopher Hummersone" <christopher.hummersone@surrey.ac.uk> wrote in message <j627oc$9oo$1@newscl01ah.mathworks.com>...
> > > Jim (and Kacey, assuming you're using similar code to Jim),
> > >
> > > You could just add these lines into your loop (after the line with the AXIS commands):
> > >
> > > sub_pos = get(gca,'position'); % get subplot axis position
> > > set(gca,'position',sub_pos.*[1 1 1.2 1.2]) % stretch its width and height
> > >
> > > Chris
> > >
> > > Jim Rockford <jim.rockford1@gmail.com> wrote in message <1180422868.162937.237240@h2g2000hsg.googlegroups.com>...
> > > > I have a 4x4 array of subplots that I'd like to make closer together
> > > > (i.e. eliminate dead space/gray space). The code that generates the
> > > > figure is
> > > >
> > > > ***********************************************
> > > > figure;
> > > > fig = gcf;
> > > > for index=1:16
> > > > pHandles(index)=subplot(4,4,index);
> > > > colormap(mycolormap); % 64x3 colormap
> > > > image(zeros(16,16)+33); % Each image is a 16x16 matrix
> > > > axis('square'); axis off;
> > > > end
> > > > set(fig,'DoubleBuffer','on');
> > > > ***********************************************
> > > >
> > > > Note: I initialize each subplot figure with a blank image, each of
> > > > which will be updated
> > > > as I collect data for my purposes.
> > > >
> > > > There is quite a bit of dead space between the individual plots. Is
> > > > there a reasonably simple way to control the size of each square? I'm
> > > > looking for a single control parameter that I can tweak until I like
> > > > the sizing. I'm running Matlab 7.1 (sp3).
> > > >
> > > > Thanks,
> > > > Jim
> > > >

Subject: Subplot matrix: remove dead space between plots

From: Per Magne Knutsen

Date: 26 Oct, 2012 01:18:08

Message: 12 of 12

Jim Rockford <jim.rockford1@gmail.com> wrote in message <1180422868.162937.237240@h2g2000hsg.googlegroups.com>...
> I have a 4x4 array of subplots that I'd like to make closer together
> (i.e. eliminate dead space/gray space). The code that generates the
> figure is
>
> ***********************************************
> figure;
> fig = gcf;
> for index=1:16
> pHandles(index)=subplot(4,4,index);
> colormap(mycolormap); % 64x3 colormap
> image(zeros(16,16)+33); % Each image is a 16x16 matrix
> axis('square'); axis off;
> end
> set(fig,'DoubleBuffer','on');
> ***********************************************
>
> Note: I initialize each subplot figure with a blank image, each of
> which will be updated as I collect data for my purposes.
>
> There is quite a bit of dead space between the individual plots. Is
> there a reasonably simple way to control the size of each square? I'm
> looking for a single control parameter that I can tweak until I like
> the sizing. I'm running Matlab 7.1 (sp3).

Jim,
I realize this is an old (!) post but after reading it having a similar issue and not finding a satisfactory answer in this thread I wrote a small function to expand and contract all axes in a figure.

function subplotsqueeze(hFig, nF)
% Stretch width and height of all subplots in a figure window
% subplotsqueeze(H, F) will stretch subplots in figure with handle H by the
% proportional factor F.
%
% Examples:
% subplotsqueeze(gcf, 1.2) will expand all axes by 20%
% subplotsqueeze(gcf, 0.8) will contract all axes by 20%
%
% Expansion and contraction is equal in both directions and axes remain
% centered on their current locations.
%
hAx = findobj(hFig, 'type', 'axes');
for h = 1:length(hAx)
    vCurrPos = get(hAx(h), 'position'); % current position
    set(hAx(h), 'position', (vCurrPos.*[1 1 nF nF])-[vCurrPos(3)*(nF-1)/2 vCurrPos(4)*(nF-1)/2 0 0]);
end
return

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us