필터 지우기
필터 지우기

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 CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by