next up previous contents index
Next: N. Custom Plot Symbols Up: M. Of colors and Previous: M.1 Built-in color palette   Contents   Index


M.2 Labeled and non-equidistant color legends

The use of color legends has already been introduced in Chapter 7 (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 table and add the -L option to the psscale 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 file), and how to switch the color bar around (by using a negative length).




#!/bin/sh
#
ps=GMT_App_M_2.ps

gmtset ANNOT_FONT_SIZE 10p MEASURE_UNIT cm

# Set up color palette with named annotations

cat > ages.cpt <<END
#COLOR_MODEL = RGB
#
0       197     0       255     23      197     0       255     ;Neogene
23      81      0       255     66      81      0       255     ;Paleogene
66      0       35      255     146     0       35      255     ;Cretaceous
146     0       151     255     200     0       151     255     ;Jurassic
200     0       255     244     251     0       255     244     ;Triassic
251     0       255     127     299     0       255     127     ;Permian
299     0       255     11      359     0       255     11      ;Carboniferous
359     104     255     0       416     104     255     0       ;Devonian
416     220     255     0       444     220     255     0       ;Silurian
444     255     174     0       488     255     174     0       ;Ordovician
488     255     58      0       542     255     58      0       ;Cambrian
B       black
F       white
END

# Top row, left to right. Using names.
psscale -Ef -Cages.cpt  -D00/13/-8/0.5    -K         > $ps
psscale -Ef -Cages.cpt  -D04/13/-8/0.5 -O -K -L     >> $ps
psscale -Ef -Cages.cpt  -D08/13/-8/0.5 -O -K -L0.0  >> $ps
psscale -Ef -Cages.cpt  -D12/13/-8/0.5 -O -K -L0.1  >> $ps
psscale -Ef -Cages.cpt  -D16/13/+8/0.5 -O -K -L     >> $ps
psscale -Ef -Cages.cpt  -D20/13/+8/0.5 -O -K -L0.1  >> $ps

# Bottom row, left to right. Using numbers.
sed 's/;.*$//' ages.cpt > years.cpt
psscale -Ef -Cyears.cpt -D00/04/+8/0.5 -O -K        >> $ps
psscale -Ef -Cyears.cpt -D04/04/-8/0.5 -O -K -L     >> $ps
psscale -Ef -Cyears.cpt -D08/04/-8/0.5 -O -K -L0.0  >> $ps
psscale -Ef -Cyears.cpt -D12/04/-8/0.5 -O -K -L0.1  >> $ps
psscale -Ef -Cyears.cpt -D16/04/-8/0.5 -O -K -Li    >> $ps
psscale -Ef -Cyears.cpt -D20/04/-8/0.5 -O    -Li0.1 >> $ps

rm -f ages.cpt years.cpt


Figure M.2: The many forms of color legends created by psscale.
\includegraphics[width=\textwidth]{scripts/GMT_App_M_2}

next up previous contents index
Next: N. Custom Plot Symbols Up: M. Of colors and Previous: M.1 Built-in color palette   Contents   Index
Paul Wessel 2008-05-02