主要内容

nebula

nebula 颜色图数组

自 R2025a 起

  • Nebula colormap

说明

c = nebula 以三列数组形式返回 nebula 颜色图,该数组包含的行数与当前图窗 (gcf) 的颜色图相同。如果不存在图窗,则行数等于默认长度 256。数组中的每一行包含一种特定颜色的红、绿、蓝强度。强度介于 [0, 1] 范围内,颜色方案如下图所示。

Sample of the nebula colormap

示例

c = nebula(m) 返回包含 m 种颜色的颜色图。

示例

示例

全部折叠

绘制一个螺旋线并分配 nebula 颜色图。

numLoops = 20;
numPtsPerLoop = 196;
theta = linspace(0,numLoops*2*pi,numPtsPerLoop);
d = exp(0.25*theta/numLoops);
x = d.*cos(theta);
y = d.*sin(theta);
s = scatter(x,y,32*d,d,"filled");
axis square
colormap nebula

Figure contains an axes object. The axes object contains an object of type scatter.

获取 nebula 颜色图数组,并反转顺序。然后将修改后的颜色图应用于该螺旋线。

c = nebula;
c = flipud(c);
colormap(c);

Figure contains an axes object. The axes object contains an object of type scatter.

默认情况下,热图使用 sky 颜色图的 256 采样。您可以通过指定 heatmap 函数的 Colormap 名称-值参量来更改颜色图和采样。

例如,在 2×1 分块图布局中创建两个热图。上图使用 nebula 颜色图的 256 种颜色,下图仅使用两种颜色。

tiledlayout(2,1)

% Top chart with default number of colors
nexttile
cdata = magic(10);
heatmap(cdata,Colormap=nebula)
title("256 Colors")

% Bottom chart with two colors
nexttile
heatmap(cdata,Colormap=nebula(2))
title("2 Colors")

Figure contains objects of type heatmap. The chart of type heatmap has title 256 Colors. The chart of type heatmap has title 2 Colors.

输入参数

全部折叠

颜色数,指定为非负整数。m 的默认值为当前图窗的颜色图中的颜色数。如果不存在图窗,则默认值为 256

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

版本历史记录

在 R2025a 中推出