getColorPalette

Purpose

Retrieves a named color palette as a string array. Some names offer multiple palettes based on the number of colors requested. These generally range from a base of 3 to a maximum of 8-12 for color brewer palettes.

Format

clrs = getColorPalette(name[, ncolors])
Parameters:

name – The name of the color palette. The full set of built-in color palettes can be seen here. The list of palettes can be queried with listColorPalettes().

Spectral
RdYlGn
RdBu*
PiYG*
PRGn*
RdYlBu*
BrBG*
RdGy
PuOr*
Set2*
Accent
Dark2*
Pastel2
Pastel1
Set1
Set3
Paired*
YlOrRd*
OrRd*
PuBu*
BuPu*
Oranges*
BuGn*
YlOrBr*
YlGn*
Reds*
RdPu*
Greens*
YlGnBu*
Purples*
GnBu*
Greys*
PuRd*
Blues*
PuBuGn*
viridis
magma
inferno
plasma
* denotes colorblind friendly palette
Parameters:

ncolors (scalar) – Optional. The desired number of colors for a specific palette. Default value is 6. If ncolors is fewer than the minimum number of colors offered by a palette, then the minimum will be returned with a warning. The same behavior occurs when ncolors is greater than the maximum number of colors a palette supports.

Returns:

clrs (ncolors x 1 string array) – hex values for each color in the palette.

Examples

Basic Usage

// Get the first 3 colors from the ColorBrewer 'Dark2' palette
clrs = getColorPalette("Dark2", 3);

After the above code, clrs should equal:

#1b9e77
#d95f02
#7570b3

These string values in clrs are hex values that describe RGB colors. They can be passed directly to any of the GAUSS plotSet functions which take a color as an input.