Find unused plot color

Version 1.1.0.0 (1.67 KB) by Deborah
Find the first unused default color in a plot or generate a random one.
304 Downloads
Updated 20 Jun 2012

View License

Whenever plots are generated inside a loop with the figure put on hold, the normal plot command plots everything in the same color. When a different color is wanted, normally a color-vector needs to be generated.
With this function it is possible to call the color inside the plot command, using
plot(x,y,'color', which_color(gca))

It first uses all the specified colors in the ColorOrder. If all of them are used it generates a random color.

Cite As

Deborah (2024). Find unused plot color (https://www.mathworks.com/matlabcentral/fileexchange/37137-find-unused-plot-color), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Axes Appearance in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.0

Simplified the way the color was determined thanks to Jan's suggestions.

1.0.0.0