# how to eliminate the blank between subplot ?

조회 수: 162(최근 30일)
Roger 2015년 5월 6일
댓글: Roger 2015년 5월 6일
what i mean is to make subplot box close to each other

댓글을 달려면 로그인하십시오.

### 채택된 답변

Use the set command and the position property. Here is one example with zero spacing between the 2x2 axes and a 0.1 frame around them:
figure, subplot(2,2,1),plot(rand(3)),set(gca,'xtick',[],'ytick',[])
subplot(2,2,2),plot(rand(3)),set(gca,'xtick',[],'ytick',[])
subplot(2,2,3),plot(rand(3)),set(gca,'xtick',[],'ytick',[])
subplot(2,2,4),plot(rand(3)),set(gca,'xtick',[],'ytick',[])
ha=get(gcf,'children');
set(ha(1),'position',[.5 .1 .4 .4])
set(ha(2),'position',[.1 .1 .4 .4])
set(ha(3),'position',[.5 .5 .4 .4])
set(ha(4),'position',[.1 .5 .4 .4])
Instead of getting the axes handles as figure children, you could also save them during creation as subplot.
##### 댓글 수: 1표시숨기기 없음
Roger 2015년 5월 6일
nice work,thanks

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

Walter Roberson 2015년 5월 6일
create all subplots first before trying to move them around. If you try to move them around before they are all created, chances are good that you will accidentally end up with subplot() deleting some of the subplots.
Once all the subplots are created, set() the Position property of their handles. For example,
for K = 1 : 6
h(K) = subplot(1,6,K);
end
set(h(2), 'Position', [.... some new location ....]);
##### 댓글 수: 1표시숨기기 없음
Roger 2015년 5월 6일
thanks ,also good

댓글을 달려면 로그인하십시오.

### 범주

Find more on Subplots in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!