Hi everyone.

I want to make shading the color of the plotted functions. I explain: for example I plot many function on the same figure, and their colors are 'b', 'g', 'r', 'c' etc... I want them shading from dark green to light green (or other color).

Here an example: the normal plot

i want this...

Any clues?? Thanks to everyone

 Respuesta aceptada

Marta Salas
Marta Salas el 27 de Mzo. de 2014

0 votos

Color is defined as a vector of 3 values: RGB. When you select 'g' on you plots this vector is [0 1 0]. 'r' is [1 0 0] or 'b' is [0 1 0]. You can customize the color for every curve:
mycolor = [0 1 0];
h = plot(x,y);
set(h,'Color', mycolor);
To know which is the values of the greens, you can look at this page, for example: http://www.rapidtables.com/web/color/RGB_Color.htm

3 comentarios

Eugenio Milanese
Eugenio Milanese el 27 de Mzo. de 2014
Thank you! Well, that's ok! But if i do multi plot like
mycolor = [0 1 0];
h = plot(x,y,x2,y2);
set(h,'Color', mycolor);
the functions are all green. And there's no way to do this:
mycolor = [0 1 0; 0 0.5 0];
h = plot(x,y,x2,y2);
set(h,'Color', mycolor);
it returns an error! Can i do this in other way? Thank you again!
Marta Salas
Marta Salas el 27 de Mzo. de 2014
Editada: Marta Salas el 27 de Mzo. de 2014
You can do it on a loop. Let's say x an y are column vectors
X = [x, x2, x3];
Y = [y, y2, y3];
mycolor = [0 1 0; 0 0.5 0; 0 0.2 0];
figure
for it=1:size(X,2)
h = plot(X(:,it), Y(:,it));
hold on
set(h,'Color', mycolor(it,:));
end
Eugenio Milanese
Eugenio Milanese el 28 de Mzo. de 2014
Thank you! that's good!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Preguntada:

el 27 de Mzo. de 2014

Comentada:

el 28 de Mzo. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by