필터 지우기
필터 지우기

Matlab subplot command not displaying all subplots

조회 수: 4 (최근 30일)
oliver
oliver 2017년 3월 11일
편집: oliver 2017년 3월 11일
I am trying to create a custom layout for 30 subplots. Since Matlab's standard settings go a bit overkill on the padding between each plot, I am trying to custom position them. The code is this:
bd=2*0.01428571; % give a total border of 0.2 in the horizontal
ww=0.8/6; % leaves a total of 0.8 to create subplots: 6 in horizontal
hh=0.8/5; % 5 in vertical
figure
for i=1:30 % total of 30 subplots
ln=ceil(i/6); % determines the line we are in (line 1 goes at the top)
cl=i-(ln-1)*6; % determines the column we are in
subplot(5,6,i,'position',[cl*bd+(cl-1)*ww (6-ln)*bd+(5-ln)*hh ww hh])
end
The code executes without problem but I end up with only about 15 subplot, the rest is empty. I have gone through it step by step and turns up that when placing certain subplots others get removed! The result is attached.
I tried it several times, changed the value for bd cause I thought it was caused by some overlap but to no avail. Is there some intrinsic limit as to how many subplots you can have or is this some (rather significant) bug in Matlab? I am using R2014b. Thanks.

답변 (1개)

oliver
oliver 2017년 3월 11일
편집: oliver 2017년 3월 11일
I found the answer myself. Instead of
subplot(5,6,i,'position',[cl*bd+(cl-1)*ww (6-ln)*bd+(5-ln)*hh ww hh])
the subplot command should be:
h(i)=subplot('position',[cl*bd+(cl-1)*ww (6-ln)*bd+(5-ln)*hh ww hh]);
I had included the 5,6,i so I could easily address individual subplots using subplot(x,y) later but it seems that this syntax was not correct, although it did not produce any errors. So better to give each one a handle h(i) and address them later with axes(h(i)).
But maybe someone could still enlighten me why I ended up with such a bizarre result before.

카테고리

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