How can I plot this with two different colors?

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!

 Respuesta aceptada

Mathieu NOE
Mathieu NOE el 29 de Oct. de 2021
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 comentarios

Pul
Pul el 29 de Oct. de 2021
Editada: Pul el 29 de Oct. de 2021
Thank you very much!
How can I create different colors from "lightBlue = [91, 207, 244] / 255"? (e.g. orange or other colors shades)
Mathieu NOE
Mathieu NOE el 29 de Oct. de 2021
My pleasure
examps of colors
cyan = [0.2 0.8 0.8];
brown = [0.2 0 0];
orange = [1 0.5 0];
blue = [0 0.5 1];
green = [0 0.6 0.3];
red = [1 0.2 0.2];
others infos available at :
see also the Matlab File exchange sections
all the best
Pul
Pul el 29 de Oct. de 2021
Thank you very much!
Mathieu NOE
Mathieu NOE el 29 de Oct. de 2021
My pleasure (again)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.

Preguntada:

Pul
el 29 de Oct. de 2021

Comentada:

el 29 de Oct. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by