Is there a way to plot two or several matrixes in one Diagramm using the same collor for respectively two Graphes?

1 visualización (últimos 30 días)
clear
close all
load Test2_-4-0.mat
A={pts.z,pts.voltage}
load Test2_0-4.mat
v=flip(pts.z)
B={v,pts.voltage}
A1=[A(:),B(:)]
plot(A1{:})
legend('v1','V2','opt','lin')
While the matrices A and B are:
Is there a way to tell Matlab it should relate to each column of the pts.voltage matrix (41x4) a specific color (or always the same color)? So two graphes have the same color.
Or some other soloution?
Without using too much code for example like:
plot(z,x(:,1),'r',z,x(:,2),'b',z,x(:,3),'g',z,x(:,4),'m')
hold on
plot(v,y(:,1),'r',v,y(:,2),'b',v,y(:,3),'g',v,y(:,4),'m')
hold off

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 3 de Dic. de 2024
The default colororder has 7 colors in it, and each series uses the next color in the colormap. Once the 7th line is used, the colororder starts over at color 1.
z = 1:100;
x(:,1) = z/10;
x(:,2) = sin(z);
x(:,3) = z/5;
x(:,4) = cos(z);
y = -x;
plot(z,x,z,y)
legend
If you do not want to specify the color, then the next option is to set the colororder using only 4 colors.
newcolors = [0.83 0.14 0.14
1.00 0.54 0.00
0.47 0.25 0.80
0.25 0.80 0.54];
figure
colororder(newcolors)
plot(z,x,z,y)
legend

Más respuestas (0)

Etiquetas

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by