gencolormap#

[cmap_ncolor] = gencolormap(cmapcolors, ncolor, dispout)

Description#

Generate a colormap from input colors

Inputs#

cmapcolors=[[255,255,255];[0,0,0]];
Colors that are used to generate colormap
Colors should be defined as [M*3] array in RGB color format
At least two colors should be defined, i.e. M should be equal or larger than 2
All values should be between 0 and 255
Any available colormap name such as ‘cool’, ‘winter’, etc also can be used
ncolor=256;

Number of colors in generated colormap

dispout=’no’;

Define to display outputs or not (‘yes’: display, ‘no’: not display)

Outputs#

cmap_ncolor
Colormap with ncolor number of colors in RGB color format between 0 and 1
To convert 0-1 scale to 0-255 scale, multiply cmap_ncolor values by 255

Examples#

%Blue-Red
[cmap_ncolor]=gencolormap([[41, 128, 185];[192, 57, 43]],256,'yes');

%Blue-White-Red
[cmap_ncolor]=gencolormap([[41, 128, 185];[255,255,255];[192, 57, 43]],256,'yes');

%Blue-White-Green
[cmap_ncolor]=gencolormap([[33, 150, 243];[255,255,255];[76, 175, 80]],256,'yes');

%Red-Brown sequential
cmapcolors=[[192,57,43];[155,89,182];[41,128,185];[39,174,96];[241,196,15];[211,84,0]];
[cmap_ncolor]=gencolormap(cmapcolors,10,'yes');

%cool colormap
[cmap_ncolor]=gencolormap('cool',256,'yes');

References#

Colormap

Color