Colorbar: label two ends with different texts

Hi all,

I have a quick question on making colorbar with customized labels, for example something like:

0	white	200 white L	; <200
200 230/230/188 300 230/230/188 L ; 200
300 195/203/160 500 195/203/160 L ; 300
500 155/175/172 800 155/175/172 L ; 500
800 115/149/184 1200 115/149/184 L ; 800
1200 78/124/195 2000 78/124/195 L ; 1200
2000 42/94/151 3000 42/94/151 L ; 2000
3000 43/30/80 4500 43/30/80 B ; 3000

B	white
F	44/26/76
N	white

image

I would like to set the right-end label to be “>4500” (currently the “3000” is misleading), but either -B or -L doesn’t work. -B actually prints the same label twice on both sides.

I was wondering if there is some way to “split” the label text and put on the two sides separately?
Thank you!

@hzfmer - as you pointed out your last color definition line in the CPT is:

3000 43/30/80 4500 43/30/80 B ; 3000 

should be

3000 43/30/80 4500 43/30/80 B ; > 4500 

For highlighting that the values in your data can go beyond the limits shown in the CPT use the -D+e option (see the manual for colorbar: " Add sidebar triangles for back- and/or foreground colors with +e ." ) instead of using a custom annotation. For custom labels, the way you’ve gone about it in the CPT looks fine to me (adding a custom string after the semicolon). There’s also the -S option in colorbar you can use.

Not sure whether I understand what you mean with

some way to “split” the label text and put on the two sides separately

The -B option lets you annotate the color changes as per your CPT definition. To put the text on different sides, again, the -D+m option lets you move different parts of the annotation to different sides of the colorbar.

I think that soon this would be available in Dev version (https://github.com/GenericMappingTools/gmt/pull/4971).

The problem has been fixed in master repo. In your case you would need to supply two secicolon-separated labels for the last slice and set annot code to B.

Thank you @chhei-s for your kind explanations! It’s great to learn these details on CPT.

Also, I think @pwessel has worked on the code to solve my problem. Thank you all!

@pwessel. With that said, would the developers consider allowing the colorbar label when -L option is turned on? For example, in the GMT cookbook you mentioned in the issue, it is not allowed to have a label like “Ages” for the colorbar, which sometimes can be useful?

Like:
image

Because we bypass the -B machinery, I think the best solution would be something like -L[i|gap][+llabel].

I agree. Hopefully it won’t be too much effort to add such option.

Awaiting approval and merging: https://github.com/GenericMappingTools/gmt/pull/4980