SetRGBArray
Prev | PHPlot Function Reference | Next

## SetRGBArray

SetRGBArray — Select a color map

## Synopsis

    $plot->SetRGBArray($color_array)

## Description

`SetRGBArray` selects a color map to use. A color map is an array of colors available to be used in the image. You can select from pre-defined color maps, or define your own. Each color in a color map has a name, and 3 or 4 color component values (red, green, blue, and optional alpha). The red, green, and blue components are in the range 0 through 255, and the optional alpha component is in the range 0 through 127.

## Parameters

`$color_array`

  An array or a string. If an array, each element defines a color in the color map. The array element key is the color name, and the array element value is an array of three or four components. (See example below).

  Or, a string selecting a built-in color map. Use 'small' to select a map of 36 colors, or 'large' to select a much larger color map.

## Notes

If SetRGBArray is not called, the 'small' color map is used.

More information about the color maps can be found in Section 3.5.2, “Built-in Color Maps”. More information about using the alpha component can be found in Section 3.6, “Truecolor Images”.

Color names are case sensitive.

For the large color map to be loaded with SetRGBArray('large'), the file `rgb.inc.php` must be found on the PHP include path or in the same directory as `phplot.php`.

When defining a color map, care must be taken to avoid invalid color errors. PHPlot uses a number of pre-defined color names, and these must either be defined in your color map or changed. If you define your own color map, it should always contain colors named 'black', 'white', and 'gray', and you should use SetDataColors and SetErrorBarColors to select colors which are in your color map.

## Examples

An example of a user-defined color map is:

        array( 'black' => array(0, 0, 0),
               'white' => array(255, 255, 255),
               'gray'  => array(190, 190, 190),
               'red'   => array(255, 0, 0),
               'green' => array(0, 255, 0),
               'blue'  => array(0, 0, 255) )

Prev | Up | Next
SetPrintImage | Home | SetShading