フィルターのクリア

How to plot shaded confidence interval?

36 ビュー (過去 30 日間)
Chetan Badgujar
Chetan Badgujar 2021 年 3 月 15 日
コメント済み: Star Strider 2021 年 3 月 16 日
Hey,
I am struggling to plot the shadded confidence interval. I have 3 variables saved in Mat. File( attached), which include mean value, lower bound and higher bound coressponding to mean value. This is what I have done so far, but it doesnot plot the shaded region.
x=1:1290;
x=x';
y=TE_U(:,1);
L = TE_U(:,2);
H= TE_U(:,3); %CI values
plot(x, y, 'k.', 'LineWidth', 2);
hold on
plot(x, L, 'r', 'LineWidth', 1);
hold on;
plot(x, H, 'b', 'LineWidth', 1);
x2 = [x, fliplr(x)];
inBetween = [L, H];
fill(L, H, 'g');
xlim([0 200])

採用された回答

Star Strider
Star Strider 2021 年 3 月 15 日
Try this:
D = load('TE_U.mat');
y = D.TE_U(:,1);
L = D.TE_U(:,2);
H = D.TE_U(:,3); %CI values
x = (1:numel(y)).'-1;
figure
plot(x, y, 'k.', 'LineWidth', 2);
hold on
plot(x, L, 'r', 'LineWidth', 1);
hold on;
plot(x, H, 'b', 'LineWidth', 1);
x2 = [x; flipud(x)];
inBetween = [L, H];
fill(x2, [L; flipud(H)], 'g', 'FaceAlpha',0.5); % Decreasing Transparency Allows Data Behind The Shading To Be seen
xlim([0 200])
producing:
.
  2 件のコメント
Chetan Badgujar
Chetan Badgujar 2021 年 3 月 16 日
Thank you @Star Strider
Star Strider
Star Strider 2021 年 3 月 16 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by