Main Content

orderedcolors

Color palettes for visualizing multiple data series

Since R2023b

    Description

    C = orderedcolors(palettename) returns the colors of a predefined color palette. For example, C = orderedcolors("gem") returns the colors of the gem color palette. Each row of the three column matrix C contains the red, green, and blue intensities for a specific color. The intensities are in the range [0, 1].

    example

    Examples

    collapse all

    Create a stacked bar chart containing four bars with five sections each.

    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.

    Change the colors of the chart to the last five colors of the 12-color gem12 palette. Get the RGB triplets of the gem12 palette and store them in matrix C. Change the colors of the chart by calling the colororder function and specifying the last five rows of the matrix.

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

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

    You can get the RGB triplets of a palette and use them to customize other aspects of your visualization. In this case, match the color of the figure to one of the palette colors.

    Create a scatter plot with the reef color palette.

    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.

    Get the RGB triplets of the color palette.

    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
    
    

    Change the color of the figure to the fifth color in the reef palette.

    f.Color = C(5,:);

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

    Input Arguments

    collapse all

    Color palette name, specified as one of the values in this table. The "gem" color palette is the default color scheme for most plots.

    Palette NamePalette Colors

    "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

    Version History

    Introduced in R2023b

    See Also

    Functions