Wednesday 11 February 2015

How to reduce the gap (space) between subplots in Matlab?

1. tight_subplot  is a very good function which does exactly the same and gives us access to control the space between subplots.

Example:

figure(140);clf

%Units are normalized to 1. 
gap = [0.005 0.005]; %lower, uppper between subplots
figureMargin_topAndBottom = [.2 .15];
figureMargin_leftAndirght = [.2 .15];


ha = tight_subplot(2,2,gap, figureMargin_topAndBottom, figureMargin_leftAndirght)

corrMs = randn(100);

for ii = 1:1:4

     axes(ha(ii)), % this is important.... this activates that particular subplot
     surf(abs(corrMs));  shading interp
        view(0,0); % viewing from x-dimension (x-z axes)
     if ii > 2
        view(90,0); % just viewing from another dimension (y-z axes)
    end
end


set(ha(2),'ZTickLabel',[]);
set(ha(4),'ZTickLabel',[]);
set(ha(1:2),'YTickLabel',[]);
set(ha(3:4),'XTickLabel',[]);

set(gcf, 'Color', 'w'); % background of the figure, outside the axes

axes(ha(3)); % this activates the axes and lets you add the attributes to that subplot
ylabel('X Data');
zlabel('Z Data');



No comments:

Post a Comment