16. Of Colors and Color Legends

16.1. Built-in color palette tables (CPT)

Figures CPTs a, b and b show the built-in color palettes, stored in so-called CPTs [35]. The programs makecpt and grd2cpt are used to access these master CPTs and translate/scale them to fit the user’s range of z-values. The top half of the color bars in the Figure shows the original color scale, which can be either discrete or continuous, though some (like globe) are a mix of the two. The bottom half the color bar are built by using makecpt -T-1/1/0.25, thus splitting the color scale into 8 discrete colors.

../_images/GMT_App_M_1a.png

The first 24 of the standard CPTs supported by GMT.

../_images/GMT_App_M_1b.png

The second 22 of the standard CPTs supported by GMT.

../_images/GMT_App_M_1c.png

The 24 scientific color maps by Fabio Crameri supported by GMT.

For additional color tables, visit cpt-city and Scientific Colour-Maps.

16.2. Labeled and non-equidistant color legends

The use of color legends has already been introduced in Examples 2, 16, and 17. Things become a bit more complicated when you want to label the legend with names for certain intervals (like geological time periods in the example below). To accomplish that, one should add a semi-colon and the label name at the end of a line in the CPT and add the -L option to the colorbar command that draws the color legend. This option also makes all intervals in the legend of equal length, even it the numerical values are not equally spaced.

Normally, the name labels are plotted at the lower end of the intervals. But by adding a gap amount (even when zero) to the -L option, they are centered. The example below also shows how to annotate ranges using -Li (in which case no name labels should appear in the CPT), and how to switch the color bar around (by using a negative length).

../_images/GMT_App_M_2.png
[35]The 3rd palette is called categorical and produces a set of colors suitable for categorical plots.