Continuous error bar across the x

2 visualizaciones (últimos 30 días)
Paola
Paola el 11 de Nov. de 2022
Respondida: DGM el 15 de Nov. de 2022
Hi all, i want to plot the mean of a data measurment with the standard deviation. I tried using boundedline but it is not working. I have just one value (y value) with the standard error to plot across the x values. can someone know how to do it.

Respuestas (1)

DGM
DGM el 15 de Nov. de 2022
What about boundedline doesn't work? If you specify y as a constant-valued vector, I don't see why it wouldn't work.
You could always just use patch() or similar.
% some fake data
x = 0:99; % or whatever x means here
err = 0.5 + 0.2*rand(1,100); % some error
err = smoothdata(err,'movmean',20); % make it smooth for the demo
y = 12.4; % some constant y-level
% boundary curves
yu = y + err;
yl = y - err;
% plot the things
yline(y);
hold on
hp = patch([x fliplr(x)],[yu fliplr(yl)],'b');
hp.FaceAlpha = 0.2;
hp.EdgeAlpha = 0;
plot(x,yu,'k--')
plot(x,yl,'k--')

Community Treasure Hunt

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

Start Hunting!

Translated by