
shaded confidence interval plotting with shade area (patch)
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello,
I'm trying to plot the shadow area between the confidence interval with the line in the middle. I've tried a few approaches, but each time I'm getting the same results (plot image). I've attached a data and code below. Please help, I don't know why I have this problem. I've read similar tags, and tried to adhere to the solutions, but it seems that doesn't work for my case.
% Using Matlab - calculations of confidence interval
pd = fitdist(X,'Normal')
ci = paramci(pd)
a4=ci(1,1)/pd.mu;
b4=ci(2,1)/pd.mu;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=X.*a4;
y=X.*b4;
Ymax=y;
Ymin=x;
figure
plot(time,Ymax)
hold on
plot(time,Ymin)
line([time(end) time(end)],[Ymin(end),Ymax(end)])
line([time(2) time(2)],[Ymin(1),Ymax(1)])
patch([time fliplr(time)], [Ymax fliplr(Ymin)], 'g')
댓글 수: 0
채택된 답변
Star Strider
2021년 4월 7일
The data in ‘data-confidence interval.xls’ are read in as column vectors, so fliplr simply flips a column vector, and accomplishes nothing. It is necessary to vertically concatenate the vectors with their flipped versons.
Try this instead:
patch([time; flipud(time)], [Ymax; flipud(Ymin)], 'g')
producing:

.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!