Pick random colors from a color map

30 次查看(过去 30 天)
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?

采纳的回答

Image Analyst
Image Analyst 2013-2-5
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 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by