MATLAB: How to create color map

bargraphcolorcolormapgraph

Hello everybody,
I plot a bargraph by using 2×500, and I need to create a colormap. However it is a bit strange colormap so I need code that, for example, all the values between 15-20 will be blue, all the values between 20-25 will be red and so on. I have never worked with bar colormap and especially with this kind of code. If someone can help I would be very glad.
Thanks in advance.

Best Answer

Use a stacked bar graph by entering an nxm matrix which will produce n bars each with m segments.
h = bar(rand(20,40), 'stacked'); % 20 bars, 40 segments each
Change the color of bars 15-20 to blue.
set(h(15:20), 'FaceColor', 'b')