How to patch upperbound and lowerbound

조회 수: 3 (최근 30일)
alpedhuez
alpedhuez 2021년 8월 23일
댓글: Star Strider 2021년 8월 23일
I read about patch to fill in the confidence interval
But I am not yet sure of how it works. (Partly due to the fact that https://www.mathworks.com/help/matlab/ref/patch.html only has graphic examples.)
Suppose I have
plot(T.date,upperbound)
hold on
plot(T.date,lowerbound)
Then how can one fill in upperbound and lowerbound?
  댓글 수: 1
alpedhuez
alpedhuez 2021년 8월 23일
편집: alpedhuez 2021년 8월 23일
I have tried https://www.mathworks.com/matlabcentral/answers/180829-shade-area-between-graphs but does not seem to work. Maybe it is because x axis is a datetimie variable?

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2021년 8월 23일
Try something like this —
T = table(datetime('now')+days(1:14).', rand(14,1), rand (14,1)+1, 'VariableNames',{'date','lowerbound','upperbound'})
T = 14×3 table
date lowerbound upperbound ____________________ __________ __________ 24-Aug-2021 15:54:18 0.3007 1.7723 25-Aug-2021 15:54:18 0.68026 1.703 26-Aug-2021 15:54:18 0.4398 1.6127 27-Aug-2021 15:54:18 0.62549 1.237 28-Aug-2021 15:54:18 0.44381 1.6517 29-Aug-2021 15:54:18 0.71737 1.3115 30-Aug-2021 15:54:18 0.41553 1.1505 31-Aug-2021 15:54:18 0.56936 1.405 01-Sep-2021 15:54:18 0.064302 1.329 02-Sep-2021 15:54:18 0.85725 1.5955 03-Sep-2021 15:54:18 0.15449 1.7525 04-Sep-2021 15:54:18 0.91195 1.8573 05-Sep-2021 15:54:18 0.10671 1.4731 06-Sep-2021 15:54:18 0.41436 1.6558
figure
patch([T.date; flipud(T.date)], [T.lowerbound; flipud(T.upperbound)], 'r', 'FaceAlpha',0.5)
grid
The patch function until recently did not work with datetime arrays, so it was necessary to use fill instead, with the same syntax as demonstrated here.
.
  댓글 수: 2
alpedhuez
alpedhuez 2021년 8월 23일
use of flipud is the key. Thank you.
Star Strider
Star Strider 2021년 8월 23일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by