Plotting many plots on same figure with unique colors
Ältere Kommentare anzeigen
Hi,
I am adding plots to a figure in my for loop as given below. I used 'Color' setting to define the colors. However there are only 7 options as per the ColorSpec given in MATLAB help. I may need to plot hundreds of plots in the same graph. How can I generate those many unique colors and then ask MATLAB to plot different lines in those colors?
colorstring = 'kbgrymckbg';
for buscnt=1:Nbus-1
for bw_combination=1:Ncomb
if bw_combination==1
figure();
end
plot(x_plot,y_plot, 'Color', colorstring(bw_combination));
hold on
end
end
Akzeptierte Antwort
Weitere Antworten (2)
Image Analyst
am 2 Mär. 2014
You can simply use any 3 element array of numbers between 0 and 1 to define whatever color you want. They don't have to be any of the specially named colors that use specific letters, for example
plot(x,y,'Color', [2., 3., .7]); % Use whatever numbers you want.
2 Kommentare
abc
am 2 Mär. 2014
Lars Abrahamsson
am 2 Sep. 2020
Moreover, it is important to avoid for example yellow, that is far too bright for white background.
Saeed Bello
am 25 Mai 2017
0 Stimmen
The link below gives a function to solve this problem:
https://www.mathworks.com/matlabcentral/fileexchange/42673-beautiful-and-distinguishable-line-colors-+-colormap
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
