Using discrete color mappings with matrix2png

[Go back to the main documentation for matrix2png]

If you use the -discrete option, your file will be interpreted as a set of discrete, non-ordered values. Integer values from 0-10 will be assigned colors from a preset list. Any other values found will be shown in grey.

Optionally, you can assign a specific mapping to be used, via the -dmap option.

Note: The discrete option is designed to work with data consisting of integer values. Data values which are not integers are coerced into integers. This may lead to unexpected results. You can have up to 256 colors in your map.

Here is an example of the file format (tab-delimited) that defines color mappings with the -dmap option in matrix2png.

value      color   label
10         red     labelA
21         blue    labelB
2          green   labelC
3          red     labelD
24         yellow  labelE
default    black   Other

The first line is a mandatory heading line. However, currently the value of this is ignored. The remainder of the file contains descriptions of the mapping of values to colors and, optionally, their meaning:

The (optional) default value is applied to data entries which do not match any of the other values in the table. By default, the default color is grey. If the default value is not needed and all of the data is explicitly mapped, it will not be shown on the scale bar.

In this example, then, the number 10 will be rendered as red; the number 24 as yellow. The number 6 will be black, because that number is not specified as having a color mapping.

The colors must be selected from the same palette available for the rest of the matrix2png color options, or using the r:g:b format where each values is an integer ranging from 0 to 255. Thus pure red is indicated by 255:0:0 while medium grey would be 128:128:128. Note that multiple values can be mapped to the same color.

Scale bars are displayed a little differently when using this option. Instead of just labeling the ends of the scale, each discrete value is indicated by its label. The label text is oriented perpendicular to the axis of the scale bar.

[Go back to the main documentation for matrix2png]

Author:

Paul Pavlidis, copyright 2002.