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

Annotations for categorical CPT #4388

Closed
seisman opened this issue Oct 27, 2020 · 6 comments · Fixed by #4390
Closed

Annotations for categorical CPT #4388

seisman opened this issue Oct 27, 2020 · 6 comments · Fixed by #4390

Comments

@seisman
Copy link
Member

seisman commented Oct 27, 2020

makecpt -F+c can produce a categorical CPT, but when plotting the colorbar, the annotations look weird. See the example below. Why the annotations are "0-1", "1-2", and "2-3". Should they be "0", "1", and "2", no?

gmt begin map png
gmt basemap -R0/10/0/10 -JX4c -Baf -BWSen
gmt makecpt -Ccubhelix -T0/3/1 -F+c
gmt colorbar
gmt end show

image

@PaulWessel
Copy link
Member

Hm, see colorbar -Li. Seems to be doing that.

@seisman
Copy link
Member Author

seisman commented Oct 27, 2020

colorbar -Li doesn't change anything.

@seisman
Copy link
Member Author

seisman commented Oct 27, 2020

BTW, the categorical CPT looks correct:

gmt makecpt -Ccubhelix -T0/3/1 -F+c
0	24/45.5/72.5	L
1	159.5/121/72.5	L
2	194/215.5/242	B
B	black
F	white
N	red

@PaulWessel
Copy link
Member

PaulWessel commented Oct 27, 2020

When colorbar plots a categorical CPT and no -B is given then it will center the annotations on each unique color and it will use as label whatever is given in the CPT (after the ; label marker per record) or, if no such labels, create one from the boundaries, i.e., 0-1, 1-2, 2-3 in your case. If I manually fix your cpt to look like this:

0 24/45.5/72.5 L ;0
1 159.5/121/72.5 L ;1
2 194/215.5/242 B ;2

then I get what you would prefer. Given this behavior is very long-lived and often reasonable, we could consider other schemes to simplify setting these labels. Here are some thoughts/suggestions for makecpt:

Let -F+c[label] 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+c Clouds,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

m

I think this is a splendid proposal no?

@PaulWessel
Copy link
Member

I think this possibility is a good improvement. Let me know if you agree, @joa-quim and @seisman.

@joa-quim
Copy link
Member

Agree. Nice adding
This is something we won't get easier on Julia and cousins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants