Patch or Fill between upper and lower bounds

조회 수: 17 (최근 30일)
Campbell Dorotich
Campbell Dorotich 2018년 10월 6일
편집: israt fatema 2023년 2월 21일
Hello Mathworks community,
I am looking to plot my upper and lower bounds with a shaded format (grey) instead of its current dotted line - no shading appearance(refer to attached image of an example). I am currently using the Gaussian Process Regression method and this would help significantly to highlight the error involved- please refer to my code provided below excluding the patch function (data is in N by 1):
Code:
tbl = readtable('m1.data.xlsx');
tbl.Properties.VariableNames = {'Temperature','Humidity','Mode1'};
gprMdl1 = fitrgp(tbl,'Mode1','KernelFunction','exponential',...
'FitMethod','Exact','PredictMethod','fic','Standardize',1);
[ytestpred,~,ytestci] = predict(gprMdl1,tbl,'Alpha',0.01);
figure();
plot(tbl.Mode1,'r','LineWidth',0.5);
hold on
plot(ytestpred,'b');
plot(ytestci(:,1),'k:');
plot(ytestci(:,2),'k:');
legend('Actual response','GPR predictions',...
'95% lower','95% upper','Location','Best');
hold off
Any help would be much appreciated.
Cheers, Cam

답변 (1개)

Star Strider
Star Strider 2018년 10월 6일
I am not certain what you want, or what you are referring to.
One option for the grey line:
x = 0:63;
y = sin(x/10);
figure
plot(x, y, '-k', 'LineWidth',2, 'Color',[1 1 1]*0.85) % Plot Grey Line
figure
patch([x(:); flipud(x(:))]', [y(:)+0.1; flipud(y(:)-0.1)]', 'k', 'FaceAlpha',0.2) % Plot ‘patch’ Object
figure
patch([x(:); flipud(x(:))]', [y(:)+0.1; flipud(y(:)-0.1)]', 'k', 'FaceAlpha',0.2, 'EdgeColor','none') % Plot ‘patch’ Object, No Edges
Experiment to get the result you want.
  댓글 수: 6
Star Strider
Star Strider 2018년 10월 6일
My pleasure.
If my Answer helped you solve your problem, please Accept it!
israt fatema
israt fatema 2023년 2월 21일
편집: israt fatema 2023년 2월 21일
@Campbell Dorotich @Star Strider Hi, this is a very useful solution for my problem. I would like to know if you also done some evaluation for your prediction interval/GPR ? I have been looking for the answer how do i qualitatively evaluate Prediction interval accuracy using GPR? TIA

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

Community Treasure Hunt

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

Start Hunting!

Translated by