### Defined

Gray-to-rgb mapping can be manually set by use of palette defined: A color gradient is defined and used to give the rgb values. Such a gradient is a piecewise linear mapping from gray values in [0,1] to the RGB space [0,1]x[0,1]x[0,1]. You must specify the gray values and the corresponding RGB values between which linear interpolation will be done.

Syntax:

         set palette  defined { ( <gray1> <color1> {, <grayN> <colorN>}... ) }

4#4grayX5#5 are gray values which are mapped to [0,1] and 4#4colorX5#5 are the corresponding rgb colors. The color can be specified in three different ways:

        <color> :=  { <r> <g> <b> | '<color-name>' | '#rrggbb' }

Either by three numbers (each in [0,1]) for red, green and blue, separated by whitespace, or the name of the color in quotes or X style color specifiers also in quotes. You may freely mix the three types in a gradient definition, but the named color `"`red`"` will be something strange if RGB is not selected as color space. Use show colornames for a list of known color names.

Please note, that even if written as 4#4r5#5, this might actually be the 4#4H5#5 component in HSV color space or 4#4X5#5 in CIE-XYZ space, or ... depending on the selected color model.

The 4#4gray5#5 values have to form an ascending sequence of real numbers; the sequence will be automatically rescaled to [0,1].

set palette defined (without a gradient definition in braces) switches to RGB color space and uses a preset full-spectrum color gradient. Use show palette gradient to display the gradient.

Examples:

To produce a gray palette (useless but instructive) use:

         set palette model RGB
         set palette defined ( 0 "black", 1 "white" )

To produce a blue yellow red palette use (all equivalent):

         set palette defined ( 0 "blue", 1 "yellow", 2 "red" )
         set palette defined ( 0 0 0 1, 1 1 1 0, 2 1 0 0 )
         set palette defined ( 0 "#0000ff", 1 "#ffff00", 2 "#ff0000" )

To produce some rainbow-like palette use:

         set palette defined ( 0 "blue", 3 "green", 6 "yellow", 10 "red" )

Full color spectrum within HSV color space:

         set palette model HSV
         set palette defined ( 0 0 1 1, 1 1 1 1 )
         set palette defined ( 0 0 1 0, 1 0 1 1, 6 0.8333 1 1, 7 0.8333 0 1)

Approximate the default palette used by MATLAB:

         set pal defined (1 '#00008f', 8 '#0000ff', 24 '#00ffff', \
                          40 '#ffff00', 56 '#ff0000', 64 '#800000')

To produce a palette with only a few, equally-spaced colors:

         set palette model RGB maxcolors 4
         set palette defined ( 0 "yellow", 1 "red" )

'Traffic light' palette (non-smooth color jumps at gray = 1/3 and 2/3).

         set palette model RGB
         set palette defined (0 "dark-green", 1 "green", \
                              1 "yellow",     2 "dark-yellow", \
                              2 "red",        3 "dark-red" )