1

How can I essentially make the white plot area occupy all the figure, not wasting the figure space with the grey area.

I could not find any propriety for it in the doc of figure,

Example of figure,

enter image description here

I want the 5 plot to be connected without any grey space outside them.

UPDATE:

set(gca,'Position',get(gca,'OuterPosition'));

this code make them stretch horizontally but not vertically.

enter image description here

SamuelNLP
  • 4,038
  • 9
  • 59
  • 102
  • how about: http://www.mathworks.com/matlabcentral/answers/43103-merging-multiple-subplots-into-a-mosaic#answer_53012 – m.s. May 21 '15 at 11:23
  • Or maybe [Subaxis](http://www.mathworks.com/matlabcentral/fileexchange/3696-subaxis-subplot) on the File Exchange ? – Benoit_11 May 21 '15 at 11:40
  • I use [subplot_tight](http://www.mathworks.com/matlabcentral/fileexchange/30884-controllable-tight-subplot) on the File Exchange. Sometimes it clips the titles or axis labels but only a teensy bit of fettling is required to fix it. – xenoclast May 21 '15 at 12:00
  • possible duplicate of [Remove deadspace or increase size of figure in subplot](http://stackoverflow.com/questions/18832406/remove-deadspace-or-increase-size-of-figure-in-subplot) – roni May 21 '15 at 17:15
  • possible duplicate of http://stackoverflow.com/questions/18853962/removing-deadspace-in-subplots-while-retaining-title-labels and http://stackoverflow.com/questions/18832406/remove-deadspace-or-increase-size-of-figure-in-subplot – roni May 21 '15 at 17:16

1 Answers1

1

First:

set(gca,'Units','normalized','Position',[0,0,1,1]);

If that doesn't help enough try:

axis normal;

EDIT: Here's a solution that works for subplots: Use the following function instead of the usual subplot function:

function varargout = tightSubplot(m,n,i)
    [x,y] = ind2sub([m,n],i);
    if nargout > 0
        varargout{1} = axes('units','normalized','position',[(x-1)/m,(y-1)/n,1/m,1/n]);
    else
        axes('units','normalized','position',[(x-1)/m,(y-1)/n,1/m,1/n]);
    end
end
Jens Boldsen
  • 1,255
  • 13
  • 21