フィルターのクリア

No gaps between subplot in for loop and shared subplot title

5 ビュー (過去 30 日間)
NA
NA 2020 年 6 月 8 日
コメント済み: NA 2020 年 6 月 8 日
Hi,
I'd really appreciate your help.
I have plotted two subplots and would like to position the Intervention and Control subplots closer together so that there are no gaps between them on the xaxis (please see figure below).
Subsequently, I would also like the subplots on each row to share the same title i.e. 0.4mA for both the Control and Intervention subplot.
My current code is:
suplotTitle = {'0.4mA', '0.6mA', '0.8mA', '1.2mA', '1.6mA'};
f1=figure('units', 'normalized', 'position', [0.001 0.001 5 5]);
for ii=1:5
s1 = subplot(6,2,2*ii-1);
b1 = bar(conRR(2:end,1), conRR(2:end, ii+1));
b1.FaceColor = '#D95319';
b1.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 70]);
title(suplotTitle{ii});
set(gca, 'FontSize', 11);
box off
if ii < 5
set(gca,'XTick',[]);
end
hold all
s2 = subplot(6,2,ii*2);
b2 = bar(b9RR(2:end,1), b9RR(2:end, ii+1));
b2.FaceColor = '#0072BD';
b2.EdgeColor = 'none';
xticks(1:1:16);
title(suplotTitle{ii});
set(gca, 'FontSize', 11);
box off
if ii < 5
set(gca,'XTick',[]);
end
set(gca,'ytick',[])
end
t = sgtitle('Respiratory Rate');
t.FontSize = 13;
t.FontWeight = 'bold';
hL = subplot(6,2,11.5);
poshL = get(hL,'position');
lgd = legend(hL,[b1,b2],'Control','Intervention');
legend box off;
set(lgd,'position',poshL,'Orientation','horizontal', 'FontSize', 11);
axis(hL,'off');
Many thanks in advance. Cheers.

採用された回答

Walter Roberson
Walter Roberson 2020 年 6 月 8 日
I have plotted two subplots and would like to position the Intervention and Control subplots closer together so that there are no gaps between them on the xaxis (please see figure below).
If you use subplot() then it is important that you create all of the subplot() first, and then only after the last one is created, you can set the OuterPosition of each. Record the handles of each as you create them: do not attempt to get the handle back by using subplot() again, not in this situation.
  3 件のコメント
NA
NA 2020 年 6 月 8 日
thank you

サインインしてコメントする。

その他の回答 (1 件)

Kevin Joshi
Kevin Joshi 2020 年 6 月 8 日
You can use the folowing,
Example plot,
You can supress the title for ONE plot and append the title to the other plot while using the 'Position' to change its location. Eaxmple: title('Hello','Position',[2 3])

カテゴリ

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