主要内容

本页翻译不是最新的。点击此处可查看最新英文版本。

orderedcolors

用于可视化多个数据序列的调色板

自 R2023b 起

    说明

    C = orderedcolors(palettename) 返回一个预定义调色板的颜色。例如,C = orderedcolors("gem") 返回 gem 调色板的颜色。三列矩阵 C 的每行包含一种特定颜色的红、绿、蓝强度。颜色强度在范围 [0, 1] 内。

    示例

    示例

    全部折叠

    创建一个包含四个条形的堆叠条形图,每个条形包含五个部分。

    y = [3 5 7 9 11; 
         2 5 6 8 10; 
         4 6 8 10 12; 
         3 5 7 9 11];
    
    bar(y,"stacked")
    legend(Location="northeastoutside")

    Figure contains an axes object. The axes object contains 5 objects of type bar.

    将图的颜色更改为 12 色 gem12 调色板的最后五种颜色。获取 gem12 调色板的 RGB 三元组,并将它们存储在矩阵 C 中。通过调用 colororder 函数并指定矩阵的最后五行来更改图的颜色。

    C = orderedcolors("gem12");
    colororder(C(8:12,:))

    Figure contains an axes object. The axes object contains 5 objects of type bar.

    您可以获得调色板的 RGB 三元组,并使用它们来自定义可视化的其他方面。在本例中,将图窗的颜色与调色板中的一种颜色匹配。

    使用 reef 调色板创建一个散点图。

    f = figure;
    scatter(rand(10,10),rand(10,10),"filled")
    colororder("reef")

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

    获取该调色板的 RGB 三元组。

    C = orderedcolors("reef")
    C = 6×3
    
        0.8660    0.3290         0
        0.3290    0.7130    1.0000
        0.0660    0.4430    0.7450
        0.9960    0.5640    0.2620
        0.4540    0.9210    0.8540
             0    0.6390    0.6390
    
    

    将图窗的颜色更改为 reef 调色板中的第五种颜色。

    f.Color = C(5,:);

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

    输入参数

    全部折叠

    调色板名称,指定为此表中的一个值。"gem" 调色板是大多数绘图的默认颜色方案。

    调色板名称调色板颜色

    "gem"(浅色主题默认值)

    Sample of the "gem" color palette

    "gem12"

    Sample of the "gem12" color palette

    "glow"(深色主题默认值)

    Sample of the "glow" color palette

    "glow12"

    Sample of "glow12" color palette

    "sail"

    Sample of the "sail" color palette

    "reef"

    Sample of the "reef" color palette

    "meadow"

    Sample of the "meadow" color palette

    "dye"

    Sample of the "dye" color palette

    "earth"

    Sample of the "earth" color palette

    版本历史记录

    在 R2023b 中推出

    全部展开

    另请参阅

    函数