Pick random colors from a color map

55 vues (au cours des 30 derniers jours)
Jared
Jared le 5 Fév 2013
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?

Réponse acceptée

Image Analyst
Image Analyst le 5 Fév 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, :)

Plus de réponses (0)

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by