How to plot shaded confidence interval?

72 visualizaciones (últimos 30 días)
Chetan Badgujar
Chetan Badgujar el 15 de Mzo. de 2021
Comentada: Star Strider el 16 de Mzo. de 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])

Respuesta aceptada

Star Strider
Star Strider el 15 de Mzo. de 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 comentarios
Chetan Badgujar
Chetan Badgujar el 16 de Mzo. de 2021
Thank you @Star Strider
Star Strider
Star Strider el 16 de Mzo. de 2021
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by