Continuous error bar across the x

3 visualizzazioni (ultimi 30 giorni)
Paola
Paola il 11 Nov 2022
Risposto: DGM il 15 Nov 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.

Risposte (1)

DGM
DGM il 15 Nov 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--')

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by