colormap using colormaps

## Description

A colormap `cmap` is defined by a m x 3 matrix of Red, Green and Blue colors intensities in the [0,1] interval. m is the number of colors defined in the colormap. The color number i is given in the ith row as a 3-uple `cmap(i,1)`, `cmap(i,2)`, `cmap(i,3)`. For a given colormap, this index i identifies the color.

The default factory colormap defines 32 colors. You can change the colormap of a figure by using `f.color_map=cmap` where `f` is the handle of the figure.

Each color in the colormap has an index you have to use to specify color in most plot functions. To see the indices, use function getcolor.

A set of functions from autumncolormap(n) to wintercolormap(n) provide swatches that can be set to colormaps. They are illustrated here-below.

The colormap of the current figure can be retrieved with `cmap = gcf().color_map`.

The current default colormap can be retrieved with `cmap = gdf().color_map`.

The factory default colormap can be retrieved with `cmap = sdf().color_map`.

## Sample

cm = ["autumn" "bone" "cool" "copper" "gray" "hot" "hsv" "jet" "ocean" .. "parula" "pink" "rainbow" "spring" "summer" "white" "winter"]; ncm = size(cm,"*"); indices = []; cmap = []; for i = 0:ncm-1 indices = [indices ; (1:100)+i*100]; execstr("cols = "+cm(i+1)+"colormap(100);"); cmap = [cmap ; cols]; end f = gcf(); clf f.color_map = cmap; Matplot(indices) xgrid([color("grey50") -1]); gca().grid_position = "foreground"; title(_("Available swatches: #colormap(100)"), "fontsize", 4); xlabel(_("Colors indices in [1,100]"), "fontsize", 3); gca().y_ticks = tlist(["ticks" "locations" "labels"],16:-1:1,cm); set(gca(), "font_size", 2, "sub_ticks",[4 0], "margins", [0.12 0.05 0.08 0.08]); gcf().axes_size = [650 650];

## Examples

    n = 64;
    r = linspace(0,1,n)';
    g = linspace(1,0,n)';
    b = ones(r);
    cmap = [r g b];
    f = gcf(); f.color_map = cmap;
    plot3d1()
    f.color_map = gdf().color_map; // restores to the default colormap

    gdf().color_map

    --> gdf().color_map
     ans  =
       0.          0.          0.
       0.          0.          1.
       0.          1.          0.
       0.          1.          1.
       1.          0.          0.
       1.          0.          1.
       1.          1.          0.
       1.          1.          1.
       0.          0.          0.5647059
       0.          0.          0.6901961
       0.          0.          0.8156863
       0.5294118   0.8078431   1.
       0.          0.5647059   0.
       0.          0.6901961   0.
       0.          0.8156863   0.
       0.          0.5647059   0.5647059
       0.          0.6901961   0.6901961
       0.          0.8156863   0.8156863
       0.5647059   0.          0.
       0.6901961   0.          0.
       0.8156863   0.          0.
       0.5647059   0.          0.5647059
       0.6901961   0.          0.6901961
       0.8156863   0.          0.8156863
       0.5019608   0.1882353   0.
       0.627451    0.2509804   0.
       0.7529412   0.3764706   0.
       1.          0.5019608   0.5019608
       1.          0.627451    0.627451
       1.          0.7529412   0.7529412
       1.          0.8784314   0.8784314
       1.          0.8431373   0.

## See also

- autumncolormap
- bonecolormap
- coolcolormap
- coppercolormap
- graycolormap
- hotcolormap
- hsvcolormap
- jetcolormap
- oceancolormap
- parulacolormap
- pinkcolormap
- rainbowcolormap
- springcolormap
- summercolormap
- whitecolormap
- wintercolormap
- color
- getcolor
- colordef