1 Download
Updated 17 Nov 2006
No License
Creates a broad range color map that looks good in color as well as when reduced to grayscale for low cost publication.
Finished colormap encodes small values with a bluish color, intermediate values in green to orange, and large values with a redish/salmon color. The greyscale is linear.
RGBcolormap=colorGray(numberOfLevels,makeDebugPlot);
Alexandre Tumlinson (2021). colorGray (https://www.mathworks.com/matlabcentral/fileexchange/12804-colorgray), MATLAB Central File Exchange. Retrieved .
Inspired: Bipolar Colormap, CubeHelix Colormap Generator: Beautiful and Versatile!, ColorBrewer: Attractive and Distinctive Colormaps, MatPlotLib Perceptually Uniform Colormaps
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Pretty nice colormap but as already noted by Will Robertson it crashes for number of leves < 3.
This can be a rough solution.
Add this after the nargin checks:
if numLevels==1
numLevels= size(colormap, 1);
realnumLevels=1;
elseif numLevels==2
numLevels= size(colormap, 1);
realnumLevels=2;
else
realnumLevels=numLevels;
end
And this before the debug plot option:
if realnumLevels==1
RGBmap = RGBmap(1,:);
elseif realnumLevels==2
RGBmap = [RGBmap(1,:); RGBmap(end,:)];
end
It looks like Mathworks has basically taken this idea and made it the new default colormap: http://blogs.mathworks.com/steve/2014/10/13/a-new-colormap-for-matlab-part-1-introduction/
Great colormap
I love this colormap. I've used it exclusively in all my MATLAB work since I discovered it. Great submission.
Other suggestion is to add line:
colormap(rgb2gray(RGBmap));colorbar
in the debugplot option to see the resulting grayscale.
What about adding a next optional parameter which would set the "darkness/lightness", such that the mapping between color and grayscale wouldn't be linear.
Easy way how to do is to add a line, e.g.
RGBmap = brighten(RGBmap,0.2)
The problem is, however, that the mapping is not smooth (as can be seen on the plot, if I do e.g. colorGray(100,1)).
I wrote something like this (independently) myself. However, it is full greyscale (i.e. black to white) and has a wider gamut of colours. It is available as the 'contrast' colourmap of the SC package (id 16233), which also has other "colour to gray" colourmaps too: 'earth', 'pinker', 'pastel'.
The code works well but it does not use the entire gray scale range.
Alex is my hero!
Great for large numbers of levels, but quite poor for just a few (e.g., if you're labelling three or four lines on a plot). In fact, the code breaks for numberOfLevels < 3. But I don't believe that's the goal of the package, so that's okay.
Colormap that unites grayscale and full color - hooray! - Where have you been all my life?!