Ahora está siguiendo esta publicación
- Verá actualizaciones en las notificaciones de contenido en seguimiento.
- Podrá recibir correos electrónicos, en función de las preferencias de comunicación que haya establecido.
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
Citar como
LittleTiger301 (2026). Remove White Space,Make Subplot Tight (https://es.mathworks.com/matlabcentral/fileexchange/118560-remove-white-space-make-subplot-tight), MATLAB Central File Exchange. Recuperado .
Agradecimientos
Inspirado por: tightly_SubPlot
Información general
- Versión 1.0.2 (2,94 KB)
Compatibilidad con la versión de MATLAB
- Compatible con cualquier versión desde R2018a
Compatibilidad con las plataformas
- Windows
- macOS
- Linux
