multiple subplots in a figure

조회 수: 1 (최근 30일)
siavash
siavash 2011년 5월 8일
I am trying to plot multiple subplots in a single figure. But some weired problem exists and some subplots are deleted !! or maybe there exists other methods to add multiple subplots.
nx=20; ny=10;
ngrids=nx*ny;
figure;
for i=1:ngrids
y=ceil((i)/nx);
x=i-(y-1)*nx;
subplot(nx,ny,i);
axis square;
set(gca,'xtick',[],'ytick',[],'Position', [((-1/nx)+x/nx) ((1-1/ny)-(y-1)/ny) (1/nx) (1/ny)]);
text(.5,.5,int2str(i),'FontSize',9,'HorizontalAlignment','center')
pause(0.001);
end

답변 (1개)

Jarrod Rivituso
Jarrod Rivituso 2011년 5월 8일
Similar question:
Main point there -> use "axes" instead of "subplot" if you are going to modify the position manually anyway.
nx=20;
ny=10;
ngrids=nx*ny;
figure;
for i=1:ngrids
y=ceil((i)/nx);
x=i-(y-1)*nx;
axes
axis square;
set(gca,'xtick',[],'ytick',[],'Position', [((-1/nx)+x/nx) ((1-1/ny)-(y-1)/ny) (1/nx) (1/ny)]);
text(.5,.5,int2str(i),'FontSize',9,'HorizontalAlignment','center')
pause(0.001);
end

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by