colormapcolormap
Mouseover text to see original. Click the button below to return to the English verison of the page.
Back to English
colormap setsthe colormap for the current figure to the built-in colormap specifiedby name. The new colormap uses the same numberof colors as the current colormap. The figure colormap affects allaxes in the figure, unless you set an axes colormap separately. Formore information, see .
colormap() setsthe colormap for the current figure to the colormap specified by map.Use this syntax if you want to use a built-in colormap with a specificnumber of colors or if you want to use a custom colormap.
For a built-in colormap with a specific number ofcolors, specify map as one of the built-in colormapfunctions and pass it an integer value as an input argument. Forexample, colormap(summer(10)) uses 10 colors fromthe summer colormap. If you do not specify thenumber of colors, such as colormap(summer), thenthe colormap contains the same number of colors as the current colormap.
For a custom colormap, specify map asa three-column matrix of values in the range [0,1] whereeach row is an RGB triplet that defines one color of the colormap.An RGB triplet is a three-element row vector specifying the red, green,and blue intensities for a color.
colormap(,) setsthe colormap for the figure, axes, or chart specified by target,instead of for the current figure.
Built-in or custom colormap, specified as one of the built-incolormap functions or a three-column matrix of RGB triplets. The defaultcolormap is parula. Versions of MATLAB priorto R2014b use jet as the default.
To use a built-in colormap with a specific number of colors,specify map as one of the built-in colormaps functionsand pass it an integer value as an input argument. For example, colormap(parula(12)) usesa map with 12 colors from the parula colormap.If you do not specify the number of colors, such as colormap(parula),then MATLAB uses the same number of colors as the current colormap.
Note:Both the name and the map inputarguments provide the same built-in colormap options. However, ifyou use the input argument name, then the colormap functionprocesses name as a character vector and you cannotcontrol the number of colors. If you use the input argument map,then the colormap function processes map asa function, which means that you can pass the built-in colormap aninteger value to control the number of colors.
This table lists the built-in colormaps functions.
Colormap NameColorScale
To create a custom colormap, specify map asa three-column matrix of RGB triplets where each row defines one color.An RGB triplet is a three-element row vector whose elements specifythe intensities of the red, green, and blue components of the color.The intensities must be in the range [0,1]. Forexample, this matrix defines a colormap containing five colors.
This table lists the RGB triplet values for common colors.
Target, specified as one of these values:
Figure object. The figure colormapaffects plots for all axes within the figure, unless you specify theaxes colormap separately.
Axes object. You can define a uniquecolormap for each Axes object. If you set the colormapfor the axes, then changing the figure colormap does not affect theaxes.
Graphics object that has a Colormap property.For example, you can change or query the colormap for a HeatmapChart object.
Colormap values, returned as a three-column matrix of RGB triplets.Each row of the matrix defines one RGB triplet that specifies onecolor of the colormap. The values are in the range [0,1].
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-39798-1.html