Centering annotations on discrete colorbar bins

Version: GMT 6.6.0
OS: Ubuntu Linux

Hello everyone,

I am trying to create a discrete horizontal colourbar where the numerical annotations sit centrally beneath each colour bin rather than at the bin edges.

Currently, if I use a simple -Bxa0.1 flag, I get a clean annotation interval, but the numbers sit firmly at the bin edges:

Above: good tick interval distribution, but sat at bin edges.

My CPT has 10 discrete intervals from 0 to 1.0 (step of 0.1). When I swtich to using the -Li flag to try and shift things into the intervals, it prints the full ranges and crowds the text layout:

gmt colorbar -C/tmp/fc.cpt \
-Dx4.5c/-1.3c+w9c/0.4c+h+jTL \
-Li \
-S+x"Frost cracking day fraction" \
--FONT_ANNOT_PRIMARY=9p,Helvetica,black

image

Above: the resulting distribution from the aforementioned code snippet.

What is the correct syntax to display these single centred annotations, instead of these range blocks?

Any help would be greatly appreciated, thanks!

Hi @henriws,

Can you also provided the code for setting up the colormap “fc.cpt” via makecpt?

For me, it works as excepted:

gmt begin color_discret png
    gmt basemap -R-1/1/-1/1 -JX5c -B
    gmt makecpt -Crainbow -T0/1/0.1
    gmt colorbar -C -DjMC+h -L0.1
gmt end show

Hey @yvonnefroehlich, here is how I make my cpt:

COLORS="#AA0000,#FF0000,#FF5500,#FFAA00,#FFFF00,#CCFF33,#5AFF1E,#00F06E,#0050FF,#0000CD"

gmt makecpt -C${COLORS} -T0/1.0/0.1 -I > /tmp/fc.cpt

Best
Henri

Thanks @yvonnefroehlich, your approach has proved successful for me!

Do you know how I can remove the gaps between these colour blocks?

Best,
Henri

You can use a gap of zero, i.e., -L0:

gmt begin color_discret_nogap png
    gmt basemap -R-1/1/-1/1 -JX5c -B
    gmt makecpt -Crainbow -T0/1/0.1
    gmt colorbar -C -DjMC+h -L0
gmt end show