Pick random colors from a color map
29 views (last 30 days)
Show older comments
I have up to 30 variables that may be plotted in 1 figure. There are 2 sets of data, each with 15 variables.
I want to have 2 seperate color maps, so I can identify each set of data.
I initially did this:
cmap1=colormap(hot(15))
cmap2=colormap(winter(15))
However, by doing this, it seems it is just using the first 15 values of each colormap. How would I go about picking 15 random colors out of the whole color map?
0 Comments
Accepted Answer
Image Analyst
on 5 Feb 2013
Try this:
% Define the two colormaps.
cmap1 = hot(15)
cmap2 = winter(15)
% Combine them into one tall colormap.
combinedColorMap = [cmap1; cmap2]
% Pick 15 rows at random.
randomRows = randi(size(combinedColorMap, 1), [15, 1])
% Extract the rows from the combined color map.
randomColors = combinedColorMap(randomRows, :)
0 Comments
More Answers (0)
See Also
Categories
Find more on Colormaps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!