フィルターのクリア

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by