Remove White Space,Make Subplot Tight
Version 1.0.2 (2,94 ko) par
LittleTiger301
Make the most use of the matlab default figure set, adjust the position of the axes of subplot , remove white space,make figure tight.
Make the most use of the matlab default figure set, adjust the position of the axes of subplot , remove white space,make figure tight.
%***********************************************************************
function [] = MakeSubplotTight(Hgcf,Nrow,Ncol)
OR
function [] = MakeSubplotTight(Hgcf,Nrow,Ncol,MarginLeft,MarginRight,MarginTop,MarginBottom,GapRow,GapCol)
%Variables: At least 3 variables,and 6 optional variables,
% Hgcf (necessary) the handle of the figure
% Nrow (necessary) the number of the Rows of subplot( or plot )
% Ncol (necessary) the number of the Columns of subplot( or plot )
**********************Demo m. file*******************************
%----------------Create Some Data For Demon Test
X(1,:)=-1000000:100000:1000000;Y(1,:)=sin(X(1,:)./57.3);
X(2,:)=-1:0.1:1;Y(2,:)=cos(X(2,:)./57.3);
X(3,:)=-1:0.1:1;Y(3,:)=X(3,:).*X(3,:);
X(4,:)=-1:0.1:1;Y(4,:)=exp(X(4,:));
%----------------Figure Of Subplot :2 Rows× 2 Columns
Hgcf=figure('color','w'); %get the handle of the figure
Nrow=2;NCol=2;
subplot(Nrow,NCol,1);plot(X(1,:),Y(1,:),'r');xlabel('X1','fontsize',12);ylabel('Y1','fontsize',12);title('Figure1','fontsize',14);legend('Y1');
subplot(Nrow,NCol,2);plot(X(2,:),Y(2,:),'r');xlabel('X2','fontsize',12);ylabel('Y2','fontsize',12);title('Figure2','fontsize',14);legend('Y2');
subplot(Nrow,NCol,3);plot(X(3,:),Y(3,:),'r');xlabel('X3','fontsize',12);ylabel('Y3','fontsize',12);title('Figure3','fontsize',14);legend('Y3');
subplot(Nrow,NCol,4);plot(X(4,:),Y(4,:),'r');xlabel('X4','fontsize',12);ylabel('Y4','fontsize',12);title('Figure4','fontsize',14);legend('Y4');
%--------------Remobe White Space,Make Subplot Tight----------------------
MakeSubplotTight(Hgcf,Nrow,NCol); %the function needs at least 3 variables——the figure handle ,the number of the rows and columns of the subplot
Citation pour cette source
LittleTiger301 (2024). Remove White Space,Make Subplot Tight (https://www.mathworks.com/matlabcentral/fileexchange/118560-remove-white-space-make-subplot-tight), MATLAB Central File Exchange. Récupéré le .
Compatibilité avec les versions de MATLAB
Créé avec
R2010b
Compatible avec les versions R2018a et ultérieures
Plateformes compatibles
Windows macOS LinuxTags
Remerciements
Inspiré par : tightly_SubPlot
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Version | Publié le | Notes de version | |
---|---|---|---|
1.0.2 | change title |
||
1.0.1 | Get rid of a few codes,make the function more effective。 |
||
1.0.0 |