colorSpectrum: Create N Distinct Plot Colors
Version 1.2.0.0 (1.39 KB) by
Kirk
Creates N distinct three-element RPB vectors for plotting
For a consistent plot lines coloring scheme. Returns a color spectrum from red to green to blue. Avoids colors that are hard to see in matlab plots, such as yellow and cyan.
Three Easy Directions:
Obtain N curves or lines to plot: Data.
Type: C = colorSpectrum(N);
Plot: figure,hold on,for i = 1:N,plot(Data(i,:),'Color',C(i,:)),end,hold off
Cite As
Kirk (2026). colorSpectrum: Create N Distinct Plot Colors (https://uk.mathworks.com/matlabcentral/fileexchange/44589-colorspectrum-create-n-distinct-plot-colors), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2013a
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
Find more on Color and Styling in Help Center and MATLAB Answers
Tags
Acknowledgements
Inspired: Maximally Distinct Color Generator
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
