Effacer les filtres
Effacer les filtres

How to plot shaded confidence interval?

36 vues (au cours des 30 derniers jours)
Chetan Badgujar
Chetan Badgujar le 15 Mar 2021
Commenté : Star Strider le 16 Mar 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])

Réponse acceptée

Star Strider
Star Strider le 15 Mar 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 commentaires
Chetan Badgujar
Chetan Badgujar le 16 Mar 2021
Thank you @Star Strider
Star Strider
Star Strider le 16 Mar 2021
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by