Page 1 of 1

Could not set the Colormap. Reason:

Posted: Thu Feb 09, 2017 3:56 am
by matlab1
Could not set the Colormap. Reason:

Re: Could not set the Colormap. Reason:

Posted: Wed Dec 30, 2020 8:11 am
by matlab1
solution :



A colormap is a matrix of values that define the colors for graphics objects such as surface, image, and patch objects. MATLABĀ® draws the objects by mapping data values to colors in the colormap.

Colormaps can be any length, but must be three columns wide. Each row in the matrix defines one color using an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. Typically, the intensities are double or single values in the range [0, 1]. A value of 0 indicates no color and a value of 1 indicates full intensity. For example, this command creates a colormap that has five colors: black, red, green, blue, and white.

Code: Select all

mymap = [0 0 0
    1 0 0
    0 1 0
    0 0 1
    1 1 1];
To change the color scheme of a visualization, call the colormap function to change the colormap of the containing axes or figure. For example, the following commands create a surface plot and set the colormap of the figure to mymap.

Code: Select all

surf(peaks)
colormap(mymap)

https://www.mathworks.com/help/matlab/ref/colormap.html