Keywords: GMT_Docs

Next: 4.16 Character escape sequences Up: 4. General features Previous: 4.14 Specifying area fill Contents Index

# 4.15 Color palette tables

Several programs, such as those which read 2-D gridded data sets and create colored images or shaded reliefs, need to be told what colors to use and over what z-range each color applies. This is the purpose of the color palette table (cpt-file). These files may also be used by psxy and psxyz to plot color-filled symbols. For most applications, you will simply create a cpt-file using the tool makecpt which will take an existing color table and resample it to fit your chosen data range, or use grd2cpt to build a cpt-file based on the data distribution in a given grid file. However, in some situations you will need to make a cpt-file by hand or using text tools like awk or perl.

The colors may be specified either in the RGB- (red, green, blue), CMYK- (cyan, magenta, yellow, black), or in the HSV-system (hue, saturation, value, and here the comment # COLOR_MODEL = HSV must be present in the cpt file since there are no other way to distinguish between HSV and RGB). Color names can also be used. Using the RGB system4.13, the format of the cpt-file is:

z | R | G | B | z | R | G | B | [A] | [;label]
... |  |  |  |  |  |  |  |  |
z | R | G | B | z | R | G | B | [A] | [;label]

Thus, for each ``z-slice'', defined as the interval between two boundaries (e.g., z to z), the color can be constant (by letting R = R, G = G, and B = B) or a continuous, linear function of z. The optional flag A is used to indicate annotation of the colorscale when plotted using psscale. The optional code A may be L, U, or B to select annotation of the lower, upper, or both limits of the particular -slice. However, the standard -B option can be used by psscale to affect annotation and ticking of colorscales. The optional semicolon followed by a text label will make psscale, when used with the -L option, place the supplied label instead of formatted z-values.

The background color (for z-values z), foreground color (for z-values z), and not-a-number (NaN) color (for z-values = NaN) are all defined in the .gmtdefaults4 file, but can be overridden by the statements

B | R | G | B
F | R | G | B
N | R | G | B

which can be inserted into the beginning or end of the cpt-file. If you prefer the HSV system, set the .gmtdefaults4 parameter accordingly and replace red, green, blue with hue, saturation, value. Color palette tables that contain grayshades only may replace the r/g/b triplets with a single grayshade in the 0-255 range. For CMYK, give four values in the 0-100 range. Both the min and max color specifications in one z-slice must use the same color system, i.e., you cannot mix ``red'' and 0/255/100 on the same line.

A few programs (i.e., those that plot polygons such as grdview, psscale, and psxy) can accept pattern fills instead of grayshades. You must specify the pattern as in Section 4.14 (no leading -G of course), and only the first (low ) is used (we cannot interpolate between patterns). Finally, some programs let you skip features whose -slice in the cptfile has grayshades set to -. As an example, consider

30 | p200/16 | 80 | - |  |  |  |  |
80 | - | 100 | - |  |  |  |  |
100 | 200 | 0 | 0 | 200 | 255 | 255 | 0 |
200 | yellow | 300 | green |  |  |  |  |

where slice is painted with pattern # 16 at 200 dpi, slice is skipped, slice is painted in a range of dark red to yellow, whereas the slice will linearly yield colors from yellow to green, depending on the actual value of .

Some programs like grdimage and grdview apply artificial illumination to achieve shaded relief maps. This is typically done by finding the directional gradient in the direction of the artificial light source and scaling the gradients to have approximately a normal distribution on the interval [-1,+1]. These intensities are used to add ``white'' or ``black'' to the color as defined by the z-values and the cpt-file. An intensity of zero leaves the color unchanged. Higher values will brighten the color, lower values will darken it, all without changing the original hue of the color (see Appendix I for more details). The illumination is decoupled from the data grd-file in that a separate grdfile holding intensities in the [-1,+1] range must be provided. Such intensity files can be derived from the data grdfile using grdgradient and modified with grdhisteq, but could equally well be a separate data set. E.g., some side-scan sonar systems collect both bathymetry and backscatter intensities, and one may want to use the latter information to specify the illumination of the colors defined by the former. Similarly, one could portray magnetic anomalies superimposed on topography by using the former for colors and the latter for shading.

Next: 4.16 Character escape sequences Up: 4. General features Previous: 4.14 Specifying area fill Contents Index