Borrar filtros
Borrar filtros

How do I add color to this line of code without repeating the time variable everytime?

1 visualización (últimos 30 días)
plot(time,[accLong,accVert,accLat,],'linewidth',2) % plot all
I do not want to use this version
plot(time,accLong,'r',time,accVert,'b',time,accLat,'k','linewidth',2) % plot all

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 24 de Sept. de 2020
Use plot handles to set the color
t = 1:10;
x1 = rand(size(t));
x2 = rand(size(t));
p = plot(t, [x1; x2]);
p(1).color = 'r'; % color of first line
p(2).color = 'b'; % color of second line
  2 comentarios
suleiman abdullahi
suleiman abdullahi el 24 de Sept. de 2020
Thanks for the response, is there another way without creating the variable p?
Ameer Hamza
Ameer Hamza el 24 de Sept. de 2020
I don't think there is an easy way. Any other solution will lead to more variables.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by