Patch or Fill between upper and lower bounds

5 vues (au cours des 30 derniers jours)
Campbell Dorotich
Campbell Dorotich le 6 Oct 2018
Modifié(e) : israt fatema le 21 Fév 2023
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

Réponses (1)

Star Strider
Star Strider le 6 Oct 2018
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 commentaires
Star Strider
Star Strider le 6 Oct 2018
My pleasure.
If my Answer helped you solve your problem, please Accept it!
israt fatema
israt fatema le 21 Fév 2023
Modifié(e) : israt fatema le 21 Fév 2023
@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

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by