How to plot the difference between two plots (using shade)

8 ビュー (過去 30 日間)
BN
BN 2021 年 10 月 3 日
コメント済み: Star Strider 2021 年 10 月 5 日
Hello everyone, I have two plots like this:
plot(OBS,'Color','#007aa5')
hold on
plot(Modeled,'Color','#ff55a3')
xlabel('time step')
Now I want to illustrate the difference between these two plots by shade like the following example:
Where plot 2 is less than plot1, the difference determines by yellow sahde and where plot 2 is greater than plot1difference determine using green shade.
I attached my datasets,
Thank you in advance
  1 件のコメント
Ravi Narasimhan
Ravi Narasimhan 2021 年 10 月 4 日
編集済み: Ravi Narasimhan 2021 年 10 月 4 日
You may need to adapt it for your case to get the different colors.

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

採用された回答

Star Strider
Star Strider 2021 年 10 月 4 日
LD1 = load('OBS[1].mat');
OBS = rmmissing(LD1.OBS);
LD2 = load('Modeled[1].mat');
Modeled = rmmissing(LD2.Modeled);
x = 1:numel(OBS);
figure
plot(OBS,'Color','#007aa5')
hold on
plot(Modeled,'Color','#ff55a3')
patch([x(:); flip(x(:))], [OBS; flip(Modeled)], 'b', 'FaceAlpha',0.25, 'EdgeColor','none')
xlabel('time step')
xlim([min(x) max(x)])
I am not certain what the ‘y’ axis is supposed to be. If the intent is that in increases from the top to the bottom (instead of the default shown here),. provide the appropriate axis tick values, then add:
set(gca, 'YDir','reverse')
.
  4 件のコメント
BN
BN 2021 年 10 月 4 日
I really appreciate you.
Star Strider
Star Strider 2021 年 10 月 5 日
Thank you!
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by