using RGB colour code while looping plots
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Robin Strak
am 17 Mär. 2020
Bearbeitet: Adam Danz
am 17 Mär. 2020
Hi,
while plotting different arrays in a loop I assigned them different colours. But as the contrast between the different colours is not very good, I´d like to have the colours in RGB code instead of the predefined 'r', 'k', ...
j = 1;
k = 1;
str = {'A1', 'A2', 'A3', 'A4'};
col = {'r', 'k', 'g', 'b'};
for i = 1:20:80
plot(M_3(i:19+i), col{k}, 'LineWidth',1);
str = [str ("Graph " + str(j))];
hold on
j = j+1;
k = k+1;
end
I thought of something like col = {4 31 74, 5 41 98}; but an error pops up.
Can you help me using another way to define different colours?
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 17 Mär. 2020
Bearbeitet: Adam Danz
am 17 Mär. 2020
Use one of the builtin colormaps or create your own nx3 RGB Color matrix where all values are between 0 and 1.
col = parula(4);
for i = 1:4
% . . . skipping stuff
plot(x,y,'Color', col(i,:))
end
Check out a list of color maps here
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Blue finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!