Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify addition of category labels to CPT files #4390

Merged
merged 3 commits into from
Oct 28, 2020
Merged

Conversation

PaulWessel
Copy link
Member

@PaulWessel PaulWessel commented Oct 27, 2020

See #4388 for background. This PR enhances the -F+c[label] in makecpt and grd2cpt to take an optional modifier argument to +c that will do the following, depending on label:

  1. If label is an integer, say 0, then we auto-add labels 0, 1, 2, ...
  2. If label is a letter (say g or G), we auto-add labels g, h, i or G, H, I
  3. If any of the above is followed by a hyphen, then we instead set labels as 0-1, 1-2, G-H, g-h, etc.
  4. If label contains a comma then we will use the comma-separated items as verbatim labels, until we run out, e.g.,
gmt makecpt -Ccubhelix -T0/3/1 -F+cClouds,Trees,Water
0	24/45.5/72.5	L	;Clouds
1	159.5/121/72.5	L	;Trees
2	194/215.5/242	B	;Water

Skipping a particular label is allowed by not providing one (e.g., Clouds,,Water).

I added a test to show the various cases (test/psscale/catlabels.sh):

catlabels

Closes #4388.

Most categorical CPTs are used for datasets that represents categories and not necessarily numerical values.  Hoever, we only offer users the ability to manuallly edit their categorical CPTS to add such labels.  This PR automaties this process.
@PaulWessel PaulWessel added the new feature PR that implements a new feature or capability in GMT label Oct 27, 2020
@PaulWessel PaulWessel self-assigned this Oct 27, 2020
@PaulWessel PaulWessel merged commit a94be07 into master Oct 28, 2020
@PaulWessel PaulWessel deleted the makecpt-cat branch October 28, 2020 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature PR that implements a new feature or capability in GMT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annotations for categorical CPT
3 participants