next up previous contents index
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. The colors may be specified either in the RGB (red, green, blue) system or in the HSV system (hue, saturation, value), and the parameter COLOR_MODEL in the .gmtdefaults file must be set accordingly. Using the RGB system, the format of the cpt-file is:

z$_0$ R$_{min}$ G$_{min}$ B$_{min}$ z$_1$ R$_{max}$ G$_{max}$ B$_{max}$ [A]
...                
z$_{n-2}$ R$_{min}$ G$_{min}$ B$_{min}$ z$_{n-1}$ R$_{max}$ G$_{max}$ B$_{max}$ [A]

Thus, for each ``z-slice'', defined as the interval between two boundaries (e.g., z$_0$ to z$_1$), the color can be constant (by letting R$_{min}$ = R$_{max}$, G$_{min}$ = G$_{max}$, and B$_{min}$ = B$_{max}$) or a continuous, linear function of z. The optional flag A is used to indicate anotation of the colorscale when plotted using psscale. A may be L, U, or B to select anotation of the lower, upper, or both limits of the particular $z$-slice. However, the standard -B option can be used by psscale to affect anotation and ticking of colorscales. The background color (for z-values $<$ z$_0$), foreground color (for z-values $>$ z$_{n-1}$), and not-a-number (NaN) color (for z-values = NaN) are all defined in the .gmtdefaults file, but can be overridden by the statements

B R$_{back}$ G$_{back}$ B$_{back}$
F R$_{fore}$ G$_{fore}$ B$_{fore}$
N R$_{nan}$ G$_{nan}$ B$_{nan}$

which can be inserted into the beginning or end of the cpt-file. If you prefer the HSV system, set the .gmtdefaults 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.

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

30 p200/16 80 -          
80 - 100 -          
100 255 0 0 200 255 255 0  

where slice $30 < z < 80$ is painted with pattern # 16 at 200 dpi, slice $80 < z < 100$ is skipped, while slice $100 < z < 200$ is painted in a range of red to yellow, depending on the actual value of $z$.

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 up previous contents index
Next: 4.16 Character escape sequences Up: 4. General features Previous: 4.14 Specifying area fill   Contents   Index
Paul Wessel 2001-04-18