View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 5 ratings Rate this file 23 Downloads (last 30 days) File Size: 14.3 KB File ID: #41583 Version: 1.0
image thumbnail



Andriy Nych (view profile)


Performs advaced colormap operations

| Watch this File

File Information

ADVANCEDCOLORMAP Performs advaced colormap operations

cmap = AdvancedColormap;
    Returns current colormap, much like COLORMAP does,
    but new figure is not created

cmaps = AdvancedColormap('GetSupportedColormaps')
    Returns cell array of strings of all predefined colormaps.

    Displays all predefined colormaps as a color+grayscale image
    or white (default) or black background.
img = AdvancedColormap('ShowSupportedColormaps',...)
    The image is returned if output parameter is specified.

str = AdvancedColormap('GetCurrentColormapString')
    Returns current colormap string.
    May not work properly if colormap was modified with commands below.

    Performs advanced command on current colormap.

    Tries to adjust current colormap so its gray values grow linearly.

    This is equivalent to MatLab


    ColorMapString String representation of colormap
        Each character represents one color
        and must belong to the following set

            char color R- G- B- values
            k black 0.0 0.0 0.0
            r red 1.0 0.0 0.0
            p pink 1.0 0.0 0.5
            o orange 1.0 0.5 0.0
            g green 0.0 1.0 0.0
            l lime 0.5 1.0 0.0
            a aquamarine 0.0 1.0 0.5
            b blue 0.0 0.0 1.0
            s sky blue 0.0 0.5 1.0
            v violet 0.5 0.0 1.0
            c cyan 0.0 1.0 1.0
            m magenta 1.0 0.0 1.0
            y yellow 1.0 1.0 0.0
            w white 1.0 1.0 1.0

        If the string does not contain spaces, each
        character represents one color in colormap.
        For example, 'kryw' defines black-red-yellow-white (hot-like) colormap
        If string contains spaces then each group of space-delimited characters
        define one color. RGB components of the color are formed
        by averagin of RGB components of each color from the group.
        For example, 'bw k rw' defines lightblue-black-lightred colormap
        Colors in the generated colormap are evenly spaced
        covering values from 0 to 1

    Length Length of generated colormap

    ColorPositions Vector of color positions
        If colors from the ColorMapString should be
        placed at custom data values, provide their positions in this vector.
        Length of the ColorPositions should be equal
        to length of the ColorMapString if ColorMapString does not contain spaces
        or to number of color groups in ColorMapString

    InterpolationMode 'nearest' {'linear'} 'spline' 'cubic'
        Interpolation mode for colormap
        See INTERP2 for details

cmap = AdvancedColormap(ColorMapString,...)
    ADVANCEDCOLORMAP returns applied colormap to caller

ctable = AdvancedColormap(ColorMapString,0);
[ctable,cpos] = AdvancedColormap(ColorMapString,0);
    When requested length of colormap is zero, ADVANCEDCOLORMAP returns
    original table of colors used to generate the colormap in CTABLE.
    This can be applied only for predefined or generated-on-the-fly colormaps.
    ADVANCEDCOLORMAP also returns vector CPOS of positions of the colors returned in CTABLE

    By inverting and reversing standard BONE colormap one can obtain nice sepia colormap



    See ADVANCEDCOLORMAPDEMO scropt for more examples

  See also colormap, brighten, FEX#23342, FEX#23865, FEX#24870, FEX#20848


Vivid Colormap, Real2rgb & Colormaps, Cold Colormap, and Fire Ice (Hot/Cold) Colormap inspired this file.

This file inspired Rgbmap Color Maps and Academic Figures.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
22 Feb 2016 Krithika Mohan

I have a data matrix with values ranging from 0 to 5500. I want to set a color , say from 0to 250, 251-500 and so on until 5500. I was trying to using this function to plot a heat map. However I was not sure how to specify the color positions based on my data.
Could you give an example for specifying custom color positions ?

Comment only
23 Dec 2015 Samrat Rao

Excellent! A very well created piece. It is so rich that i'll take some time to even understand its usage.

24 Jun 2014 William

Excellent submission. Works great for procedurally generating colormaps to fit simulation outcomes.

21 Jan 2014 Andrew

Andrew (view profile)

Very nice tool for creating custom colormaps. I was able to match a fairly tricky colormap from a figure I had been given with very little effort. Thanks!

21 Jan 2014 Andrew

Andrew (view profile)

21 Jan 2014 Andrew

Andrew (view profile)

Contact us