# ColorSpec

## Purpose

Color specification.

## Description

`ColorSpec` is not a command, rather it refers to the three ways in which you specify color in MATLAB:

- Short name
- Long name
- RGB triple
  The short names and long names are MATLAB strings that specify one of eight predefined colors. The following table lists the predefined colors and their RGB equivalents.

      -------------------------------
      RGB Value  Short Name  Long Name
      -------------------------------
      [1 1 0]    y           yellow
      [1 0 1]    m           magenta
      [0 1 1]    c           cyan
      [1 0 0]    r           red
      [0 1 0]    g           green
      [0 0 1]    b           blue
      [1 1 1]    w           white
      [0 0 0]    k           black

      -------------------------------

  The RGB triple 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].

  When you specify an RGB triple that is not one of the eight listed above, MATLAB allocates a slot in the system color table for the new color. Colors defined in this way are true colors as opposed to colors mapped to the closest entry that already exists in the color table.

  The eight predefined colors and any that you specify as RGB values are not part of the figure colormap, nor are they affected by changes to the figure colormap. They are referred to a fixed colors, as opposed to colormap colors.

  ## Examples

  To create a plot that uses a green line color, specify the color with either a short name, a long name, or an RGB triple. These statements are equivalent:

      plot(xdata,ydata,'g')

      plot(xdata,ydata,'green')

      h = plot(xdata,ydata);
      set(h,'Color',[0 1 0])

  You can use a `ColorSpec` anywhere you need to define a color. For example, this statement changes the figure background color to pink:

      set(gcf,'Color',[1  .4  .6])

  ## See Also

  `colormap`

  (c) Copyright 1994 by The MathWorks, Inc.