How can I plot this with two different colors?

1 回表示 (過去 30 日間)
Pul
Pul 2021 年 10 月 29 日
コメント済み: Mathieu NOE 2021 年 10 月 29 日
Hello everyone,
i should plot this line with 2 different color:until 2010 it should be light blue and the other part green (including triangles).
load('giulia_year')
plot(giulia_year.DateA, giulia_year.Diff_Values,'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g')
Can anyone help me?
Thank you!

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 10 月 29 日
hello
here you are :
code :
load('giulia_year')
ind1 =find(giulia_year.DateA <= datetime('31-Dec-2010'));
ind2 =find(giulia_year.DateA > datetime('31-Dec-2010'));
ind2 = [ind1(end); ind2]; % keep plot continuity
lightBlue = [91, 207, 244] / 255;
plot(giulia_year.DateA(ind1), giulia_year.Diff_Values(ind1),'Color',lightBlue,'LineStyle','-' ,'Marker','^','MarkerEdgeColor','k','MarkerFaceColor',lightBlue)
hold on
plot(giulia_year.DateA(ind2), giulia_year.Diff_Values(ind2),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g')
hold off
  4 件のコメント
Pul
Pul 2021 年 10 月 29 日
Thank you very much!
Mathieu NOE
Mathieu NOE 2021 年 10 月 29 日
My pleasure (again)

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

その他の回答 (0 件)

カテゴリ

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