How to decrease the gap between figures in subplot

조회 수: 3 (최근 30일)
Tallha Akram
Tallha Akram 2012년 12월 25일
댓글: Gunjan Rateria 2020년 6월 11일
Hi,
I am displaying 8 images using subplot (2,4,I), but there is enough margin between images which results in small picture size . How can i decrease the margin between pictures?
Thanks.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 12월 25일
편집: Azzi Abdelmalek 2012년 12월 25일
tailx=0.2
taily=0.4
marg=0.05
y1=0.55
y2=0.1
x0=0.02
v=zeros(8,4)
v(1,:)=[x0 y1 tailx taily]
for k=2:4
v(k,1)=v(k-1,1)+tailx+marg
end
v(:,2)=y1
v(:,3)=tailx
v(:,4)=taily
v(5:8,:)=v(1:4,:);
v(5:8,2)=y2
for k=1:8
subplot(2,4,k),h=plot(t,y);
set(gca,'position',v(k,:))
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 12월 25일
Be careful: if you subplot() on top of a location that already has an axes at all, then the existing axes will be removed.
Gunjan Rateria
Gunjan Rateria 2020년 6월 11일
Thanks Azzi! Your code worked like a charm for me after playing around with some numbers. Can you explain a little bit about the terms you have used and how this can be modified if I have say 10 subplots(2,5). Really appreciate your help :)

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

추가 답변 (1개)

Image Analyst
Image Analyst 2012년 12월 25일
Set the position property of each subplot. Something like (untested)
h = subplot(2,2,1);
set(h, 'Position', [.1 .9 .4 .4]);
or something like that.

카테고리

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