CUBEHELIX is the only colormap-generator you will ever need for MATLAB: CUBEHELIX generates colormaps for published or distributed documents as they are very attractive in full color and yet are suitable for grayscale conversion.
CUBEHELIX creates different colormaps using just a few parameters. The standard algorithm offer very attractive colorschemes for online and electronic documents (e.g. PDF), and yet when printed in grayscale they keep exactly the sequence information of the original data. CUBEHELIX function also includes two extra controls over the range and domain of the colormap values, giving a practically unlimited number of colormaps with many different styles: maximally distinct, multi or single hue, and may be suitable for grayscale printing or even simple grayscale.
### Algorithm ###
CUBEHELIX colorschemes consist of nodes along a tapered helix in the RGB color cube, with a continuous increase in perceived intensity (e.g. black->white). Thus the scheme defines attractive colormaps with a huge choice of hue, saturation and brightness, and yet printing a figure (or image) in Black-and-White (e.g. postscript) results in a monotonically increasing grayscale that retains the brightness order of the original colormap. The sequence information of the colormap is retained even in grayscale, which means an attractive colored image can be printed in grayscale and still be informative to the end-user.
The CUBEHELIX algorithm is defined here: http://astron-soc.in/bulletin/11June/289392011.pdf
For more information and examples: http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/
### Examples ###
% New colors for the COLORMAP example:
S = load('spine');
image(S.X)
colormap(cubehelix) % default parameters
% New colors for the SURF example:
[X,Y,Z] = peaks(30);
surfc(X,Y,Z)
colormap(cubehelix([],0.5,-1.5,1,1,[0.29,0.92]))
axis([-3,3,-3,3,-10,5])
### Bonus Function ###
CUBEHELIX_VIEW creates an interactive figure that allows selection of the colorscheme, and that contains two colorbars showing colors of the colormap and the grayscale equivalent.
R2014b or later: CUBEHELIX_VIEW can also update other axes' or figures' colormaps in real time, for example:
S = load('spine');
image(S.X)
cubehelix_view(gca)
### Notes ###
* The original specification (the links above) misnamed the saturation option as "hue". In the CUBEHELIX function the saturation option is named "satn".
Stephen Cobeldick (2021). CubeHelix Colormap Generator: Beautiful and Versatile! (https://github.com/DrosteEffect/CubeHelix), GitHub. Retrieved .
Inspired by: colorGray, SC - powerful image rendering, Light Bartlein Color Maps, Vivid Colormap, Cold Colormap, Red Blue Colormap, Haxby color map, Bipolar Colormap, Color Palette Tables (.cpt) for Matlab, Perceptually improved colormaps, contourfcmap: filled contour plot with precise colormap, Generate maximally perceptually-distinct colors, Matlab colormaps as seen by color-blind users, stoplight, othercolor, colorGradient: generate custom linear colormaps, Colormaps compatible with red-green color perception deficiencies, cbrewer : colorbrewer schemes for Matlab, POLARMAP: Polarized colormap, Build custom colormaps, Custom colormap, Beautiful and distinguishable line colors + colormap, ColorBrewer: Attractive and Distinctive Colormaps, Intuitive RGB color values from XKCD, rgbmap color maps, hslcolormap, Perceptually uniform colormaps
Inspired: squink(Colors,Gamma), paruly, Maximally Distinct Color Generator, Convert between RGB and Color Names, jetwhite(Colours), cmocean perceptually-uniform 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.
Fantastic color map generator. I use this all the time.
@rockthekasbah: You would need to generate two colormaps, and concatenate them vertically, something like this:
map1 = cubehelix(10,2,2,1,1);
map2 = cubehelix(10,1,0,1,1);
map = [map1;map2(end:-1:1,:)];
I spent quite some time investigating this concept myself, with the intention of writing a wrapper function that returns a diverging colormap constructed from two cubehelix maps. However the huge number of input parameters (up to eight values for each cubehelix map) made it a users nightmare. Determining the color of the midpoint is not a simple task: should it be automatically determined? If so, how? What happens if the user defines two maps with very different colors at the join: what would the mid-point color be? Should the function force the user to make the adjacent colors match?
In the end I decided that because concatenating two colormaps is trivially easy, it was not worth the complexity of its own function.
How do I create a diverging colormap out of this? I played around with different settings but it is taking forever to find one. Is there an easier way?
Excellent function. Works well, creates nice colours that do not trick the reader and prints well in gray scales. It does what it is supposed to do.