How to plot two different styles of confidence intervals in looped subplots?
古いコメントを表示
I have a plot with 6 variables and 5 subplot. In one case, the third variable, I want it to display two lines in one graph. So far, it is fine. However, I also need confidence intervals to differ in shap for this subplot, the alternative ones should be dashaded while the others shaded. I don't know how to do it.
This is an example (data on attached excel file):
data = xlsread('prova.xls') % Data
lines = data(:, 1:5)
line2 = data(:, 16)
ci = data(:, 6:15)
ci2 = data(:,17:18)
k = 5 % plot
for j = 1:k
subplot(3, 2, j);
plot(lines(:,j), 'LineWidth',1,'Color', [0 0 0.5]);
hold on
if j == 3
plot(line2, 'LineWidth',1,'Color', [0 0 0.5], 'LineStyle','--')
end
hold on
plot(ci,'LineWidth',1,'Color', [0 0 0.5],'LineStyle','--');
hold on
% plot(ci2,'LineWidth',1,'Color', [0 0 0.5],'LineStyle','--'); % don't know how to plot it
% I tried: if j == 3
% plot(ci2, 'LineWidth',1,'Color', [0 0 0.5], 'LineStyle','--mo')
% end but it didn't work
yline(0, '-')
end
I would like the code to be modified to embed: a) the confidence intervals of the second dataset only in subplot 3; b) a different confidence interval's style (shaded vs dashed). I am stuck and don't know how to do it unfortunately.
Is there anyone who can help me?
Thanks!
7 件のコメント
It looks like you're plotting CIs as lines which doesn't make sense to me. Even if the lines are CI bounds, I'd explect to see upper and lower bounds. I understand that your data are 'fake data' and it's helpful that you've provided an example that we can run. But it's not clear how a line object can be shaded.
Armando MAROZZI
2020 年 5 月 30 日
Armando MAROZZI
2020 年 5 月 30 日
Adam Danz
2020 年 5 月 30 日
The '--mo' linestyle correctly throws an error. It should also throw an error for you. This isn't related to the main problem but it should be corrected. A linestye cannot contain the marker type or color. It can be changed to '--'.
Armando MAROZZI
2020 年 5 月 30 日
Adam Danz
2020 年 5 月 30 日
The updated demo is still confusing.
For example, instead of plotting ci as lines, I plotted them as circular markers and this is the first subplot. It's not clear how those markers are supposed to represent confidence intervals.

Armando MAROZZI
2020 年 5 月 30 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
