shadow the area between two curves in a plot

6 ビュー (過去 30 日間)
Patrick Reinwald
Patrick Reinwald 2020 年 5 月 14 日
回答済み: Image Analyst 2020 年 5 月 17 日
in my figure i have plottet 3 curves. the first one is from the data gathered and the other two are the confidence interval. I now want to shadow the area between the confidencial interval (best in grey) but until now i failed miserably. Can someoene help me?
figure
subplot(3,1,1)
plot(average_a_A_plot_cont1,'DisplayName','average_a_A_plot_cont1'); %curve from the data
hold on
plot(ci_durch1(:,:)); %curves from the confidence interval
hold off
title('limited memory; memory length =5, umwsd 5, 25, 45 ');
ylim([0 1])
xlabel('Timesteps')
ylabel('Performance')
grid on
pbaspect([1 1 1])

採用された回答

Star Strider
Star Strider 2020 年 5 月 14 日
I do not have your data, so I created my own.
You may have to change it slightly to fit your intended application.
Try this:
x = (1:20).'; % Create Independent Variable Vector
y = 2 + 3*x + randn(size(x))*10; % Create Dependent Variable Vector
mdl = fitlm(x, y); % Estimate Parameters
[ypred,ci] = predict(mdl,x); % Calculate Regression & Confidence Intervals
figure
plot(x, y, 'p')
hold on
patch([x; flipud(x)], [ci(:,1); flipud(ci(:,2))], [1 1 1]*0.8, 'EdgeColor','none', 'FaceAlpha',0.2)
plot(x, ypred, '-r')
hold off
grid
The patch call creates the shaded confidence intervals.
  2 件のコメント
Patrick Reinwald
Patrick Reinwald 2020 年 5 月 17 日
Thanks for your help
Star Strider
Star Strider 2020 年 5 月 17 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 5 月 17 日
With the code sample in the FAQ, you get:

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by