#### 3.25.54 palette

Palette is a color storage for use by pm3d, filled color contours or polygons, color histograms, color gradient background, and whatever it is or it will be implemented... Here it stands for a palette of smooth "continuous" colors or grays, but let’s call it just a palette.

Color palettes require terminal entries for filled color polygons and palettes of smooth colors, are currently available for terminals listed in help for pm3d. The range of color values are adjustable independently by cbrange and ‘set log cb‘. The whole color palette is visualized in the ‘colorbox‘.

Syntax:

          set palette
          set palette {
                     { gray | color }
                     { gamma <gamma> }
                     {   rgbformulae <r>,<g>,<b>
                       | defined { ( <gray1> <color1> {, <grayN> <colorN>}... ) }
                       | file '<filename>' {datafile-modifiers}
                       | functions <R>,<G>,<B>
                     }
                     { cubehelix {start <val>} {cycles <val>} {saturation <val>} }
                     { model { RGB | HSV | CMY | YIQ | XYZ } }
                     { positive | negative }
                     { nops_allcF | ps_allcF }
                     { maxcolors <maxcolors> }
                   }
          show palette
          show palette palette <n> {{float | int}}
          show palette gradient
          show palette fit2rgbformulae
          show palette rgbformulae
          show colornames

palette (i.e. without options) sets up the default values. Otherwise, the options can be given in any order. palette shows the current palette properties.

‘show palette gradient‘ displays the gradient defining the palette (if appropriate). rgbformulae prints the available fixed gray –> color transformation formulae. colornames prints the known color names.

‘show palette palette <n>‘ prints to the screen or to the file given by print a table of RGB triplets calculated for the current palette settings and a palette having <n> discrete colors. The default wide table can be limited to 3 columns of r,g,b float values [0..1] or integer values [0..255] by options float or int, respectively. This way, the current gnuplot color palette can be loaded into other imaging applications, for example Octave. Additionally to this textual list of RGB table, you can use the palette command to plot the R,G,B profiles for the current palette.

The following options determine the coloring properties.

Figure using this palette can be ‘gray‘ or ‘color‘. For instance, in pm3d color surfaces the gray of each small spot is obtained by mapping the averaged z-coordinate of the 4 corners of surface quadrangles into the range [min_z,max_z] providing range of grays [0:1]. This value can be used directly as the gray for gray maps. The color map requires a transformation gray –> (R,G,B), i.e. a mapping [0:1] –> ([0:1],[0:1],[0:1]).

Basically two different types of mappings can be used: Analytic formulae to convert gray to color, or discrete mapping tables which are interpolated. rgbformulae and functions use analytic formulae whereas defined and ‘palette file‘ use interpolated tables. rgbformulae reduces the size of postscript output to a minimum.

The command ‘show palette fit2rgbformulae‘ finds the best matching rgbformulae for the current palette. Naturally, it makes sense to use it for non-rgbformulae palettes. This command can be found useful mainly for external programs using the same rgbformulae definition of palettes as gnuplot, like zimg ( http://zimg.sourceforge.net ).

‘set palette gray‘ switches to a gray only palette. rgbformulae, defined, ‘set palette file‘ and functions switch to a color mapping. ‘set palette color‘ is an easy way to switch back from the gray palette to the last color mapping.

Automatic gamma correction via ‘set palette gamma <gamma>‘ can be done for gray maps (‘set palette gray‘) and for the cubehelix color palette schemes. Gamma = 1 produces a linear ramp of intensity. See palette.

Many terminals support only discrete number of colors (e.g. 256 colors in gif). After the default gnuplot linetype colors are allocated, the rest of the available colors are by default reserved for pm3d. Thus a multiplot using multiple palettes could fail because the first palette has used all the available color positions. You can mitigate this limitation by using ‘set palette maxcolors <N>‘ with a reasonably small value of N. This option causes N discrete colors to be selected from a continuous palette sampled at equally spaced intervals. If you want unequal spacing of N discrete colors, use defined instead of a single continuous palette.

RGB color space might not be the most useful color space to work in. For that reason you may change the color space with ‘model‘ to one of ‘RGB‘, ‘HSV‘, ‘CMY‘, ‘YIQ‘ and ‘XYZ‘. Using color names for defined tables and a color space other than RGB will result in funny colors. All explanation have been written for RGB color space, so please note, that ‘R‘ can be ‘H‘, ‘C‘, ‘Y‘, or ‘X‘, depending on the actual color space (‘G‘ and ‘B‘ accordingly).

All values for all color spaces are limited to [0,1].

RGB stands for Red, Green and Blue; CMY stands for Cyan, Magenta and Yellow; HSV stands for Hue, Saturation, and Value; YIQ is the color model used by the U.S. Commercial Color Television Broadcasting, it is basically an RGB recoding with downward compatibility for black and white television; XYZ are the three primary colors of the color model defined by the ’Commission Internationale de l’Eclairage’ (CIE). For more information on color models see: http://en.wikipedia.org/wiki/Color_space