In MATLAB, each figure has (and only) a colormap, which translates to a color map .
COLORMAP (map) maps the current graph's color map with a map matrix.
the default setting forCOLORMAP (' Default ') is JET.
MAP = COLORMAP Gets the current color graph matrix .
COLORMAP (Ax,...) applies a color map to a graphic that corresponds to ax coordinates, not to the current drawing.
ColorMap is actually a mx3 matrix, each row of 3 values is 0-1, respectively, representing the color of the RGB values , such as [0 0 1] for blue. The system comes with some colormap, such as:Winter, Autumn and so on . Enter winter and you can see that it is a 64x3 matrix. Users can customize their own colormap and are not necessarily 64-dimensional .
So how exactly does the color appear in fill or patch? Essentially, it turns the specific color into the corresponding index in the ColorMap , which is the number of rows. This process is called conversion mapping : Maps the specified numeric color vector (matrix) C to the corresponding color.
In MATLAB, the property ' cdatamapping ' of the graphics window defaults to 'scaled', which is the linear mapping .
The mapping process is as follows:
First, you need to get cmin and Cmax two variables based on Caxis (the default is 0 and 1), and if you specify a numeric color vector (matrix) c,cmin and Cmax are automatically set to the maximum and minimum values in C when drawing. You can customize it when you want to control it. For example, reduce the Cmax so that all C values greater than Cmax are mapped to the same color (the color represented by the index's largest row in ColorMap).
based on the proportional relationship between CIJ in Cmin and Cmax, the index of the corresponding color is determined, and the default is linear mapping.
That is, when the numerical color vector (matrix) c is drawn, the use range of the colors in the image will automatically fill the entire color range!!!
In addition, the color values for some points are specified in fill, and the other color values are determined by interpolation.
Example 1:
ColorMap ([Winter;autumn;summer])% is equivalent to customizing the ColorMap of a 64*3 dimension
X=[0 1 1 0];
Y=[0 0 1 1];
Fill (x,y,[0 0.1 0.2 0.3]);% is cmin=0,cmax=0.3
colorbar;% Show Color Chart bar
The result of the operation is as follows: Example 2:% the color from [0 0 0] to [1 1 0] in this example
% increase the value of row_cmap, such as change to 100, you can see the color of the gradient, rather than jump-type changes. Row_cmap = 15; % defines the number of rows for a color graph matrix
Color_map1=zeros (row_cmap,3); % Definition Color Graph matrix
Color_r = 0:1/(row_cmap-1): 1;
Color_g = 0:1/(row_cmap-1): 1;
Color_b = 0:1/(row_cmap-1): 1;
COLOR_MAP1 (:, 1) = Color_r;
Color_map1 (:, 2) = Color_g;
ColorMap (COLOR_MAP1);
Colorbar;
In my case, the ColorMap (Gray (128))
Indicates that the map color of this graph is a grayscale 128 grayscale, that is, a black-and-white image. Gry (128) is an array of 128x3, and the r=g=b in it. Organized from: Http://hi.baidu.com/stinkbug/blog/item/dd475343dee7c9129313c6fc.htmlhttp://blog.sina.com.cn/s/blog_ 618af1950100eyp4.htmlhttp://blog.sina.com.cn/s/blog_6163bdeb0100h1zl.html
Matlab_ function ColorMap