ColorSpec is not a function; it refers to
the three ways in which you specify color for MATLAB® graphics:
The short names and long names are character vectors that specify one of eight predefined colors. The 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]. The following table lists the predefined colors and their RGB triplet equivalents.
This code makes the x-axis red.
ax = gca; ax.XColor = 'red';
This code changes the figure background color to pink:
fig = gcf; fig.Color = [1 0.4 0.6];
The eight predefined colors and any colors you specify as RGB triplets are not part of a figure's colormap, nor are they affected by changes to the figure's colormap. They are referred to as fixed colors, as opposed to colormap colors.
In most cases, you can specify a color using either an RGB triplet
or a character vector of a color name. However, in some cases, you
cannot specify the color as a color name. For example, you cannot
CData property of a scatter object to
a color name.