Filter löschen
Filter löschen

How to plot shaded confidence interval?

36 Ansichten (letzte 30 Tage)
Chetan Badgujar
Chetan Badgujar am 15 Mär. 2021
Kommentiert: Star Strider am 16 Mär. 2021
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])

Akzeptierte Antwort

Star Strider
Star Strider am 15 Mär. 2021
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 Kommentare
Chetan Badgujar
Chetan Badgujar am 16 Mär. 2021
Thank you @Star Strider
Star Strider
Star Strider am 16 Mär. 2021
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by