Skip to content

Commit

Permalink
Improve support for categorical CPTs (#4446)
Browse files Browse the repository at this point in the history
* Simplify how to set string keys for categorical CPTs

We recently made it simpler to add CPT labels via -F+c.  Now, we use a similar mechanism to add string keys to replace numerical look up values for cateborical CPTs via -F+kkeys.  A few more checks on the number of labels and keys were added as well.  Fixed the bug where a categorical request for -T1/n/1 did not include n.

* Update features.rst

* Update makecpt.c

* Update catlabels.sh

* UPdate docs

* Let makecpt -T take categories and remove +k from grd2cpt (must be numerical, duh)

* Update makecpt.c
  • Loading branch information
PaulWessel authored Nov 13, 2020
1 parent 6b7ad27 commit 012e437
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 30 deletions.
3 changes: 3 additions & 0 deletions doc/rst/source/cookbook/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,9 @@ overridden by the statement
| N | Fill\ :sub:`nan` |
+-----+---------------------+

While you can make such categorical CPTs by hand, both :doc:`/makecpt` and :doc:`/grd2cpt` have options to
simplify adding string keys and labels from comma-separated arguments.

Regular CPTs
~~~~~~~~~~~~

Expand Down
18 changes: 14 additions & 4 deletions doc/rst/source/makecpt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Synopsis
[ |-C|\ *cpt* ]
[ |-D|\ [**i**\|\ **o**] ]
[ |-E|\ [*nlevels*] ]
[ |-F|\ [**R**\|\ **r**\|\ **h**\|\ **c**][**+c**\ [*label*]]]
[ |-F|\ [**R**\|\ **r**\|\ **h**\|\ **c**][**+c**\ [*label*]][**+k**\ *keys*] ]
[ |-G|\ *zlo*\ /\ *zhi* ]
[ |-H| ]
[ |-I|\ [**c**][**z**] ]
Expand Down Expand Up @@ -111,7 +111,7 @@ Optional Arguments

.. _-F:

**-F**\ [**R**\|\ **r**\|\ **h**\|\ **c**][**+c**\ [*label*]]
**-F**\ [**R**\|\ **r**\|\ **h**\|\ **c**][**+c**\ [*label*]][**+k**\ *keys*]
Force output CPT to be written with r/g/b codes, gray-scale values
or color name (**R**, default) or r/g/b codes only (**r**), or h-s-v
codes (**h**), or c/m/y/k codes (**c**). Optionally or alternatively,
Expand All @@ -121,7 +121,11 @@ Optional Arguments
category names (you can skip a category by not giving a name), or give
*start*\ [-], where we automatically build monotonically increasing labels
from *start* (a single letter or an integer). Append - to build ranges
*start*\ -*start+1* instead.
*start*\ -*start+1* instead. If the categorical CPT should have string
keys instead of numerical entries then append **+k**\ *keys*, where
*keys* is either a file with one key per record or a single letter (e.g., D),
then we build sequential letter keys (e.g., D, E, F, ...) starting at that point.
For comma-separated lists of keys, use **-T** instead.

.. _-G:

Expand Down Expand Up @@ -194,7 +198,9 @@ Optional Arguments
not given, the existing range in the master CPT will be used intact.
The values produces defines the color slice boundaries. If **+n** is
used it refers to the number of such boundaries and not the number of slices.
For details on array creation, see `Generate 1D Array`_.
For details on array creation, see `Generate 1D Array`_. **Note**: To set
up categorical CPTs with string keys you can also give a comma-separated
list of your keys.

.. _-V:

Expand Down Expand Up @@ -328,6 +334,10 @@ To instead add unique category labels A, B, C, ... to a 10-item categorical CPT,

gmt makecpt -Cjet -T0/10/1 -F+cA

To make a categorical CPT with string keys instead of numerical lookup values, try::

gmt makecpt -Ccategorical -Twood,water,gold

.. include:: cpt_notes.rst_

Bugs
Expand Down
2 changes: 1 addition & 1 deletion src/gmt_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ EXTERN_MSC bool gmt_this_alloc_level (struct GMT_CTRL *GMT, unsigned int alloc_l

EXTERN_MSC bool gmt_is_barcolumn (struct GMT_CTRL *GMT, struct GMT_SYMBOL *S);
EXTERN_MSC unsigned int gmt_get_columbar_bands (struct GMT_CTRL *GMT, struct GMT_SYMBOL *S);
EXTERN_MSC char ** gmt_cat_cpt_labels (struct GMT_CTRL *GMT, char *label, unsigned int n);
EXTERN_MSC char ** gmt_cat_cpt_strings (struct GMT_CTRL *GMT, char *label, unsigned int n);
EXTERN_MSC bool gmt_same_fill (struct GMT_CTRL *GMT, struct GMT_FILL *F1, struct GMT_FILL *F2);
EXTERN_MSC unsigned int gmt_contour_first_pos (struct GMT_CTRL *GMT, char *arg);
EXTERN_MSC unsigned int gmt_contour_A_arg_parsing (struct GMT_CTRL *GMT, char *arg, struct CONTOUR_ARGS *A);
Expand Down
11 changes: 10 additions & 1 deletion src/gmt_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -5787,6 +5787,8 @@ GMT_LOCAL int gmtsupport_compare_sugs (const void *point_1, const void *point_2)

/*! . */
uint64_t gmt_read_list (struct GMT_CTRL *GMT, char *file, char ***list) {
/* Reads a file with one string per line. Returns number of strings an
* allocated pointer to the array */
uint64_t n = 0;
size_t n_alloc = GMT_CHUNK;
char **p = NULL, line[GMT_BUFSIZ] = {""};
Expand Down Expand Up @@ -7407,7 +7409,7 @@ unsigned int gmt_validate_cpt_parameters (struct GMT_CTRL *GMT, struct GMT_PALET
return GMT_NOERROR;
}

char ** gmt_cat_cpt_labels (struct GMT_CTRL *GMT, char *label, unsigned int n) {
char ** gmt_cat_cpt_strings (struct GMT_CTRL *GMT, char *label, unsigned int n) {
/* Generate categorical labels for n categories from the label magic argument */
unsigned int k = 0;
char **Clabel = gmt_M_memory (GMT, NULL, n, char *);
Expand All @@ -7421,6 +7423,9 @@ char ** gmt_cat_cpt_labels (struct GMT_CTRL *GMT, char *label, unsigned int n) {
k++;
}
gmt_M_str_free (orig);
if (k != n) {
GMT_Report (GMT->parent, GMT_MSG_WARNING, "The comma-separated string %s had %d entries but %d were expected\n", label, k, n);
}
}
else { /* Auto-build the labels */
unsigned int mode;
Expand All @@ -7429,10 +7434,14 @@ char ** gmt_cat_cpt_labels (struct GMT_CTRL *GMT, char *label, unsigned int n) {
if (isdigit (label[0])) { /* Integer categories */
mode = 1;
start = atoi (label);
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "Building %d sequential strings from integers starting at %d\n", n, start);
}
else { /* Letter categories */
mode = 3;
start = label[0];
if (strlen (label) > 1)
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "Expected a single letter to initialize auto-labels but found %s.\n", label);
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "Building %d sequential strings from letters starting at %c\n", n, start);
}
if (label[strlen(label)-1] == '-') mode++; /* Wants a range */
for (k = 0; k < n; k++) {
Expand Down
9 changes: 5 additions & 4 deletions src/grd2cpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Message (API, GMT_TIME_NONE, "\t comma-separated list of category names, or <start>[-], where we automatically build\n");
GMT_Message (API, GMT_TIME_NONE, "\t labels from <start> (a letter or an integer). Append - to build ranges <start>-<start+1>.\n");
GMT_Message (API, GMT_TIME_NONE, "\t-G Truncate incoming CPT to be limited to the z-range <zlo>/<zhi>.\n");
GMT_Message (API, GMT_TIME_NONE, "\t If <keys> is a single letter then we build sequential alphabetical keys from that letter.\n");
GMT_Message (API, GMT_TIME_NONE, "\t To accept one of the incoming limits, set that limit to NaN.\n");
if (API->GMT->current.setting.run_mode == GMT_MODERN)
GMT_Message (API, GMT_TIME_NONE, "\t-H Also write CPT to stdout [Default just saves as current CPT].\n");
Expand Down Expand Up @@ -211,7 +212,7 @@ static int parse (struct GMT_CTRL *GMT, struct GRD2CPT_CTRL *Ctrl, struct GMT_OP

int n;
unsigned int n_errors = 0, pos = 0, n_files[2] = {0, 0};
char txt_a[GMT_LEN128] = {""}, txt_b[GMT_LEN32] = {""}, *c = NULL;
char txt_a[GMT_LEN512] = {""}, txt_b[GMT_LEN32] = {""}, *c = NULL;
char *T_arg = NULL, *S_arg = NULL;
struct GMT_OPTION *opt = NULL;
struct GMTAPI_CTRL *API = GMT->parent;
Expand Down Expand Up @@ -284,7 +285,7 @@ static int parse (struct GMT_CTRL *GMT, struct GRD2CPT_CTRL *Ctrl, struct GMT_OP
if (gmt_validate_modifiers (GMT, opt->arg, 'F', "c", GMT_MSG_ERROR)) n_errors++;
if (gmt_get_modifier (opt->arg, 'c', txt_a)) {
Ctrl->F.cat = true;
Ctrl->F.label = strdup (txt_a);
if (txt_a[0]) Ctrl->F.label = strdup (txt_a);
}
Ctrl->F.active = true;
switch (txt_a[0]) {
Expand Down Expand Up @@ -840,8 +841,8 @@ EXTERN_MSC int GMT_grd2cpt (void *V_API, int mode, void *args) {
if (Ctrl->F.active) Pout->model = Ctrl->F.model;
if (Ctrl->F.cat) { /* Flag as a categorical CPT */
Pout->categorical = GMT_CPT_CATEGORICAL_VAL;
if (Ctrl->F.label[0]) { /* Want categorical labels */
char **label = gmt_cat_cpt_labels (GMT, Ctrl->F.label, Pout->n_colors);
if (Ctrl->F.label) { /* Want categorical labels */
char **label = gmt_cat_cpt_strings (GMT, Ctrl->F.label, Pout->n_colors);
for (unsigned int k = 0; k < Pout->n_colors; k++) {
if (Pout->data[k].label) gmt_M_str_free (Pout->data[k].label);
Pout->data[k].label = label[k]; /* Now the job of the CPT to free these strings */
Expand Down
90 changes: 76 additions & 14 deletions src/makecpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ struct MAKECPT_CTRL {
bool active;
unsigned int levels;
} E;
struct MAKECPT_F { /* -F[r|R|h|c][+c[<label>]] */
struct MAKECPT_F { /* -F[r|R|h|c][+c[<label>]][+k<keys>] */
bool active;
bool cat;
unsigned int model;
char *label;
char *key;
} F;
struct MAKECPT_G { /* -Glow/high for input CPT truncation */
bool active;
Expand Down Expand Up @@ -134,6 +135,7 @@ static void Free_Ctrl (struct GMT_CTRL *GMT, struct MAKECPT_CTRL *C) { /* Deallo
gmt_M_str_free (C->Out.file);
gmt_M_str_free (C->C.file);
gmt_M_str_free (C->F.label);
gmt_M_str_free (C->F.key);
gmt_free_array (GMT, &(C->T.T));
gmt_M_free (GMT, C);
}
Expand All @@ -142,7 +144,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
const char *H_OPT = (API->GMT->current.setting.run_mode == GMT_MODERN) ? " [-H]" : "";
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
GMT_Message (API, GMT_TIME_NONE, "usage: %s [-A<transparency>[+a]] [-C<cpt>|colors] [-D[i|o]] [-E<nlevels>] [-F[R|r|h|c][+c[<label>]]] [-G<zlo>/<zhi>]%s\n", name, H_OPT);
GMT_Message (API, GMT_TIME_NONE, "usage: %s [-A<transparency>[+a]] [-C<cpt>|colors] [-D[i|o]] [-E<nlevels>] [-F[R|r|h|c][+c[<label>]][+k<keys>]] [-G<zlo>/<zhi>]%s\n", name, H_OPT);
GMT_Message (API, GMT_TIME_NONE, "\t[-I[c][z]] [-M] [-N] [-Q] [-S<mode>] [-T<min>/<max>[/<inc>[+b|l|n]] | -T<table> | -T<z1,z2,...zn>] [%s] [-W[w]]\n\t[-Z] [%s] [%s] [%s]\n\t[%s] [%s]\n\n",
GMT_V_OPT, GMT_bi_OPT, GMT_di_OPT, GMT_i_OPT, GMT_ho_OPT, GMT_PAR_OPT);

Expand All @@ -163,7 +165,10 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Message (API, GMT_TIME_NONE, "\t Append +c[label>] to output a discrete CPT in categorical CPT format.\n");
GMT_Message (API, GMT_TIME_NONE, "\t The <label>, if present, sets the labels for each category. It may be a\n");
GMT_Message (API, GMT_TIME_NONE, "\t comma-separated list of category names, or <start>[-], where we automatically build\n");
GMT_Message (API, GMT_TIME_NONE, "\t labels from <start> (a letter or an integer). Append - to build ranges <start>-<start+1>.\n");
GMT_Message (API, GMT_TIME_NONE, "\t labels from <start> (a letter or an integer). Append - to build range labels <start>-<start+1>.\n");
GMT_Message (API, GMT_TIME_NONE, "\t Append +k<keys> to set categorical keys rather than numerical values.\n");
GMT_Message (API, GMT_TIME_NONE, "\t <keys> may be a file with one key per line or a comma-separated list of keys.\n");
GMT_Message (API, GMT_TIME_NONE, "\t If <keys> is a single letter then we build sequential alphabetical keys from that letter.\n");
GMT_Message (API, GMT_TIME_NONE, "\t-G Truncate incoming CPT to be limited to the z-range <zlo>/<zhi>.\n");
GMT_Message (API, GMT_TIME_NONE, "\t To accept one of the incoming limits, set that limit to NaN.\n");
if (API->GMT->current.setting.run_mode == GMT_MODERN)
Expand Down Expand Up @@ -196,6 +201,18 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
return (GMT_MODULE_USAGE);
}

GMT_LOCAL unsigned int makecpt_is_categories (struct GMT_CTRL *GMT, char *arg) {
char txt[GMT_LEN64] = {""};
/* Return n if -T was given a list of category string keys rather than numerical info [0] */
if (arg == NULL || arg[0] == '\0') return 0; /* Nothing at all */
if (strchr (arg, '/')) return 0; /* Looks like xmin/xmax/xinc */
if (strchr (arg, ',') == NULL) return 0; /* No comma, no list of any type */
sscanf (arg, "%[^,]", txt);
if (gmt_not_numeric (GMT, txt)) /* Return the number of commas plus one */
return (gmt_count_char (GMT, arg, ',') + 1);
return 0;
}

static int parse (struct GMT_CTRL *GMT, struct MAKECPT_CTRL *Ctrl, struct GMT_OPTION *options) {
/* This parses the options provided to makecpt and sets parameters in CTRL.
* Any GMT common options will override values set previously by other commands.
Expand All @@ -204,8 +221,8 @@ static int parse (struct GMT_CTRL *GMT, struct MAKECPT_CTRL *Ctrl, struct GMT_OP
*/

int n;
unsigned int n_errors = 0, n_files[2] = {0, 0};
char txt_a[GMT_LEN512] = {""}, txt_b[GMT_LEN32] = {""}, *c = NULL;
unsigned int n_errors = 0, n_files[2] = {0, 0}, n_categorical = 0;
char txt_a[GMT_LEN512] = {""}, txt_b[GMT_LEN32] = {""}, *c = NULL, *keys = NULL;
struct GMT_OPTION *opt = NULL;

for (opt = options; opt; opt = opt->next) if (opt->option == 'Q') Ctrl->Q.active = true;; /* If -T given before -Q we need to flag -T+l */
Expand Down Expand Up @@ -255,10 +272,14 @@ static int parse (struct GMT_CTRL *GMT, struct MAKECPT_CTRL *Ctrl, struct GMT_OP
break;
case 'F': /* Sets format for color reporting */
Ctrl->F.active = true;
if (gmt_validate_modifiers (GMT, opt->arg, 'F', "c", GMT_MSG_ERROR)) n_errors++;
if (gmt_validate_modifiers (GMT, opt->arg, 'F', "ck", GMT_MSG_ERROR)) n_errors++;
if (gmt_get_modifier (opt->arg, 'c', txt_a)) {
Ctrl->F.cat = true;
Ctrl->F.label = strdup (txt_a);
if (txt_a[0]) Ctrl->F.label = strdup (txt_a);
}
if (gmt_get_modifier (opt->arg, 'k', txt_a)) {
Ctrl->F.cat = true;
if (txt_a[0]) Ctrl->F.key = strdup (txt_a);
}
switch (opt->arg[0]) {
case 'r': Ctrl->F.model = GMT_RGB + GMT_NO_COLORNAMES; break;
Expand Down Expand Up @@ -321,7 +342,11 @@ static int parse (struct GMT_CTRL *GMT, struct MAKECPT_CTRL *Ctrl, struct GMT_OP
break;
case 'T': /* Sets up color z values */
Ctrl->T.active = Ctrl->T.interpolate = true;
n_errors += gmt_parse_array (GMT, 'T', opt->arg, &(Ctrl->T.T), GMT_ARRAY_TIME | GMT_ARRAY_DIST | GMT_ARRAY_RANGE | GMT_ARRAY_NOINC | GMT_ARRAY_UNIQUE, GMT_Z);
n_categorical = makecpt_is_categories (GMT, opt->arg);
if (n_categorical == 0)
n_errors += gmt_parse_array (GMT, 'T', opt->arg, &(Ctrl->T.T), GMT_ARRAY_TIME | GMT_ARRAY_DIST | GMT_ARRAY_RANGE | GMT_ARRAY_NOINC | GMT_ARRAY_UNIQUE, GMT_Z);
else
keys = strdup (opt->arg);
if (Ctrl->T.T.set == 2) Ctrl->T.interpolate = false; /* Did not give increment, just min/max */
break;
case 'Q': /* Logarithmic scale */
Expand Down Expand Up @@ -349,6 +374,18 @@ static int parse (struct GMT_CTRL *GMT, struct MAKECPT_CTRL *Ctrl, struct GMT_OP
}
}

if (n_categorical) { /* Must do some shuffling */
if (Ctrl->F.key) {
GMT_Report (GMT->parent, GMT_MSG_COMPAT, "Option -T: Cannot set categorical keys with both -T and -F+k.\n");
n_errors++;
}
else {
Ctrl->F.cat = true; /* Must turn on categorical whether -F was set of not */
Ctrl->F.key = keys;
sprintf (txt_a, "1/%d/1", n_categorical); /* Build replacement array setup */
n_errors += gmt_parse_array (GMT, 'T', txt_a, &(Ctrl->T.T), GMT_ARRAY_UNIQUE, GMT_Z);
}
}
/* Given -Qo and -T...+l are the same, make sure both ways are defined since code uses both */
if (Ctrl->Q.active && Ctrl->Q.mode == 2) Ctrl->T.T.logarithmic = true;
else if (Ctrl->T.T.logarithmic) Ctrl->Q.active = true, Ctrl->Q.mode = 2;
Expand Down Expand Up @@ -431,7 +468,7 @@ EXTERN_MSC int GMT_makecpt (void *V_API, int mode, void *args) {
Return (API->error);
}
if (Ctrl->T.active && (API->error = gmt_validate_cpt_parameters (GMT, Pin, Ctrl->C.file, &(Ctrl->T.interpolate), &(Ctrl->Z.active))))
Return (API->error)
Return (API->error)

if (Ctrl->Q.active && Pin->has_hinge)
GMT_Report (API, GMT_MSG_WARNING, "CPT %s has a hinge but you selected a logarithmic scale\n", Ctrl->C.file);
Expand Down Expand Up @@ -533,7 +570,15 @@ EXTERN_MSC int GMT_makecpt (void *V_API, int mode, void *args) {

/* Set up arrays */

if (Ctrl->T.active && gmt_create_array (GMT, 'T', &(Ctrl->T.T), NULL, NULL)) Return (GMT_RUNTIME_ERROR);
if (Ctrl->T.active) {
if (gmt_create_array (GMT, 'T', &(Ctrl->T.T), NULL, NULL))
Return (GMT_RUNTIME_ERROR);
if (Ctrl->F.cat && Ctrl->T.T.n > 1) { /* Must go one more increment to output what the user wants */
Ctrl->T.T.n++;
Ctrl->T.T.array = gmt_M_memory (GMT, Ctrl->T.T.array, Ctrl->T.T.n, double);
Ctrl->T.T.array[Ctrl->T.T.n-1] = Ctrl->T.T.array[Ctrl->T.T.n-2] + 1; /* Does not matter as long as > previous */
}
}
nz = (int)Ctrl->T.T.n; z = Ctrl->T.T.array;

if (Ctrl->T.T.list && (Pin->mode & GMT_CPT_TEMPORARY)) { /* Array was passed as a comma-separated list of z-values so make sure it matches a list of colors, if given */
Expand Down Expand Up @@ -595,13 +640,30 @@ EXTERN_MSC int GMT_makecpt (void *V_API, int mode, void *args) {
if (Ctrl->F.active) Pout->model = Ctrl->F.model;
if (Ctrl->F.cat) { /* Flag as a categorical CPT */
Pout->categorical = GMT_CPT_CATEGORICAL_VAL;
if (Ctrl->F.label[0]) { /* Want categorical labels */
char **label = gmt_cat_cpt_labels (GMT, Ctrl->F.label, Pout->n_colors);
if (Ctrl->F.label || Ctrl->F.key) { /* Want categorical labels appended to each CPT record */
char **label = gmt_cat_cpt_strings (GMT, (Ctrl->F.label) ? Ctrl->F.label : Ctrl->F.key, Pout->n_colors);
for (unsigned int k = 0; k < Pout->n_colors; k++) {
if (Pout->data[k].label) gmt_M_str_free (Pout->data[k].label);
Pout->data[k].label = label[k]; /* Now the job of the CPT to free these strings */
if (label[k]) Pout->data[k].label = label[k]; /* Now the job of the CPT to free these strings */
}
gmt_M_free (GMT, label); /* But the master array can go */
}
if (Ctrl->F.key) { /* Want categorical labels */
char **keys = NULL;
if (!gmt_access (GMT, Ctrl->F.key, R_OK)) { /* Got a file with category keys */
unsigned int ns = gmt_read_list (GMT, Ctrl->F.key, &keys);
if (ns < Pout->n_colors) {
GMT_Report (API, GMT_MSG_WARNING, "The categorical keys file %s had %d entries but %d were expected\n", Ctrl->F.key, ns, Pout->n_colors);
}
}
else /* Got comma-separated keys */
keys = gmt_cat_cpt_strings (GMT, Ctrl->F.key, Pout->n_colors);
for (unsigned int k = 0; k < Pout->n_colors; k++) {
if (Pout->data[k].key) gmt_M_str_free (Pout->data[k].key);
if (keys[k]) Pout->data[k].key = keys[k]; /* Now the job of the CPT to free these strings */
}
gmt_M_free (GMT, label);
gmt_M_free (GMT, keys); /* But the master array can go */
Pout->categorical = GMT_CPT_CATEGORICAL_KEY;
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/psscale/catlabels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# Testing the auto-labeling of categorical CPTs.
ps=catlabels.ps
gmt set FONT_ANNOT_PRIMARY 9p,Helvetica,black
gmt makecpt -T0/4/1 -Ccubhelix -F+c > t.cpt
gmt makecpt -T0/3/1 -Ccubhelix -F+c > t.cpt
gmt psxy -R0/20/0/30 -Jx1c -P -K -Y0 -T > $ps
gmt psscale -O -K -Ct.cpt -Dx8c/22c+w12c/0.5c+jTC+h -Y2.5c >> $ps
gmt psscale -O -K -Ct.cpt -Dx8c/19c+w12c/0.5c+jTC+h -Bxaf >> $ps
gmt psscale -O -K -Ct.cpt -Dx8c/16c+w12c/0.5c+jTC+h -Li0.4c >> $ps
gmt makecpt -T0/4/1 -Ccubhelix -F+cNight,Trees,Sediment,Water > t.cpt
gmt makecpt -T0/3/1 -Ccubhelix -F+cNight,Trees,Sediment,Water > t.cpt
gmt psscale -O -K -Ct.cpt -Dx8c/13c+w12c/0.5c+jTC+h -Li0.4c >> $ps
gmt makecpt -T0/4/1 -Ccubhelix -F+cA > t.cpt
gmt makecpt -T0/3/1 -Ccubhelix -F+cA > t.cpt
gmt psscale -O -K -Ct.cpt -Dx8c/10c+w12c/0.5c+jTC+h >> $ps
gmt makecpt -T0/4/1 -Ccubhelix -F+c1 > t.cpt
gmt makecpt -T0/3/1 -Ccubhelix -F+c1 > t.cpt
gmt psscale -O -K -Ct.cpt -Dx8c/7c+w12c/0.5c+jTC+h >> $ps
gmt makecpt -T0/4/1 -Ccubhelix -F+c9- > t.cpt
gmt makecpt -T0/3/1 -Ccubhelix -F+c9- > t.cpt
gmt psscale -O -K -Ct.cpt -Dx8c/4c+w12c/0.5c+jTC+h >> $ps
gmt makecpt -T0/4/1 -Ccubhelix -F+cG- > t.cpt
gmt makecpt -T0/3/1 -Ccubhelix -F+cG- > t.cpt
gmt psscale -O -Ct.cpt -Dx8c/1c+w12c/0.5c+jTC+h -Li0.4c >> $ps

0 comments on commit 012e437

Please sign in to comment.