Continuous error bar across the x

조회 수: 4 (최근 30일)
Paola
Paola 2022년 11월 11일
답변: DGM 2022년 11월 15일
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.

답변 (1개)

DGM
DGM 2022년 11월 15일
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--')

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by