文档

colormap

查看并设置当前的colormap

句法

colormap图
菌落(map)
菌落(目标,,,,map)
cmap =colormap
cmap =菌落(目标)

Description

例子

colormapmap将当前图的结肠设置为预定义的一个结肠之一。除非您分别设置轴的结肠,否则该图的结肠会影响图中的所有轴。新的菌落与当前的colormap相同的长度(颜色数)。当您使用此语法时,无法为Colormap指定自定义长度。要了解有关菌落的更多信息,请参阅什么是菌落?

例子

菌落(map将当前图的结肠设置为由map

例子

菌落(目标,,,,mapsets the colormap for the figure, axes, or chart specified by目标,,,,instead of for the current figure.

例子

cmap= colormap返回当前图的结肠,作为RGB三胞胎的三列矩阵。

例子

cmap= colormap(目标返回图形,轴或图表的colormap目标

Examples

collapse all

Create a surface plot and set the colormap towinter

figure surf(peaks) colormapwinter

首先,将当前图的菌落图更改为summer

figure surf(peaks) colormapsummer

现在将ColorMap设置回系统的默认值。如果尚未指定其他默认值,则默认colormap为戒律

colormap默认

Create a figure with two subplots and store the axes handles,AX1andAX2。通过将轴手柄传递到colormap功能。In the upper subplot, create a surface plot using the春天结肠。In the lower subplot, create a surface plot using thewinter结肠。

figure ax1 = subplot(2,1,1); surf(peaks) colormap(ax1,spring) ax2 = subplot(2,1,2); surf(peaks) colormap(ax2,winter)

通过将整数作为输入参数传递给内置的colormap,指定colormap中使用的颜色数量。使用Parula Colormap中的五种颜色。

图网(峰)结肠(Parula(5))

通过定义0.0至1.0之间的三列矩阵来创建自定义colormap。每行定义了三元素RGB三重态。第一列指定红色强度。第二列指定绿色强度。第三列指定蓝色强度。

Use a colormap of blue values by setting the first two columns to zeros.

map = [0, 0, 0.3 0, 0, 0.4 0, 0, 0.5 0, 0, 0.6 0, 0, 0.8 0, 0, 1.0]; figure surf(peaks) colormap(map)

Create a surface plot of thepeaks功能并指定一个菌落。

图网(峰)菌落(秋季(5))

返回定义图中使用的颜色的值的三列矩阵。每一行都是RGB三重态值,它指定了Colormap的一种颜色。

cmap =colormap
cmap =1。0000001。0000 0.2500 0 1.0000 0.5000 0 1.0000 0.7500 0 1.0000 1.0000 0

Return the colormap values for a specific axes by passing its axes handle to thecolormap功能。

创建一个带有两个子图的图形,然后返回轴手柄,AX1andAX2。在每个轴上添加一个填充的轮廓图,并为每个轴使用不同的菌落。

figure ax1 = subplot(2,1,1); contourf(peaks) colormap(ax1,hot(8)) ax2 = subplot(2,1,2); contourf(peaks) colormap(ax2,pink)

通过传递其轴手柄,返回上部子图中使用的结肠值AX1,到colormap功能。每一行都是RGB三重态值,它指定了Colormap的一种颜色。

cmap =菌落(AX1)
cmap =0.3333 0 0 0.6667 0 0 1.0000 0 0 0 1.0000 0.3333 0 1.0000 0.6667 0 1.0000 1.0000 0 1.0000 1.0000 1.0000 0.5000 1.0000 1.0000 1.0000 1.0000 1.0000

Load the脊柱返回图像的数据集Xand its associated colormapmap。DisplayXusing the图片function and set the colormap tomap

加载脊柱图图像(x)colormap(地图)

Input Arguments

collapse all

颜色map for the new color scheme, specified as a colormap name, a three-column matrix of RGB triplets, or'default'。A colormap name specifies a predefined colormap with the same number of colors as the current colormap. A three-column matrix of RGB triplets specifies a custom colormap. You can create the matrix yourself, or you can call one of the predefined colormap functions to create the matrix. For example,菌落(戒律(10))集的colormap the current figure to a selection of 10 colors from the戒律结肠。

一个值'default'将colormap设置为目标对象的默认colormap。

颜色map Name

下表列出了预定义的菌落。

颜色map Name 颜色Scale
戒律

喷射

HSV

热的

cool

春天

summer

秋天

winter

灰色的

pink

线

Colorcube

prism

flag

白色的

Three-Column Matrix

要创建自定义colormap,请指定mapas a three-column matrix of RGB triplets where each row defines one color. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1]。For example, this matrix defines a colormap containing five colors.

MAP = [0.2,0.1,0.5 0.1,0.5,0.8 0.2,0.7,0.6 0.8,0.7,0.7,0.3 0.9,1,0];

This table lists the RGB triplet values for common colors.

颜色 RGB三胞胎
黄色 [1,1,0]
magenta [1,0,1]
cyan [0,1,1]
红色的 [1,0,0]
绿色 [0,1,0]
蓝色的 [0,0,1]
白色的 [1,1,1]
黑色的 [0,0,0]

数据类型:char|double

目标,指定为以下值之一:

  • 数字目的。The figure colormap affects plots for all axes within the figure.

  • Axes目的or极性目的。You can define a unique colormap for the different axes within a figure.

  • Graphics object that has a颜色mapproperty. For example, you can change or query the colormap for aHeatmapChart目的。

输出参数

collapse all

颜色map values, returned as a three-column matrix of RGB triplets. Each row of the matrix defines one RGB triplet that specifies one color of the colormap. The values are in the range [0, 1].

更多关于

collapse all

什么是菌落?

colormap是在0and1这定义了图形对象(例如表面,图像和补丁对象)的颜色。MATLAB®通过将数据值映射到colormap中的颜色来绘制对象。

颜色maps 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. The intensities must be in the range [0, 1]. A value of0indicates no color and a value of1表示完全强度。例如,此命令创建一个具有五种颜色的菌落:黑色,红色,绿色,蓝色和白色。

myMap = [0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1];

To change the color scheme of a visualization, call thecolormapfunction 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 tomymap

surf(peaks) colormap(mymap)

Compatibility Considerations

从R2014B开始,默认colormap为戒律。在以前的版本中,默认的colormap是喷射

Tips

  • 要控制菌落的限制,以及这些限制与数据范围之间的关系,请使用caxis功能。

Introduced before R2006a

Was this topic helpful?