フィルターのクリア

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 Center および File ExchangeSubplots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by