Make CPT with custom intervals and colors

A seemingly simple task, but I’m having trouble making a (custom) CPT.

I want a CPT like this:

hypso

What’s the best way to do this?

I’m very happy by some syntax-help; the actual colors I want I can find myself once I know how to do it!

I tried playing with gmt makecpt -E -Ccol1,col2…, but - issues…

Edit: Tweaking a cpt by hand works, but is messy.

Have you looked into the example script (bottom of the page, click the “show” button)?

1 Like

Thanks @PlanetGus; a kick in the general direction of docs tend to help.

Here’s an example of my script:

gmt begin color-test png

# hand made
cat<<eof > temp.cpt
-6000 #627890 -5000 #627890
-5000 #65a8c2 -4000 #65a8c2
-4000 #4db7cf -3000 #4db7cf
-3000 #87b1c7 -2000 #87b1c7
-2000 #72c3d6 -1000 #72c3d6
-1000 #91d2e4 -500 #91d2e4
-500 #aad6da -300 #aad6da
-300 #94c8a1 -200 #94c8a1
-200 #b3d5ba -100 #b3d5ba
-100 #c5dbcf 0 #c5dbcf
0 #ecc58e 1 #ecc58e
eof

# run through makecpt to get proper cpt (i.g. back- and foreground and NaN)
# pipe through sed to replace B with L to only annotate Lower (not Both) for slice 0 - 1
gmt makecpt -Ctemp.cpt -D -H | sed 's/B$/L/g' > color.cpt

# plot - illustration below uses @earth_relief_02m
gmt grdimage @earth_relief_02m -RSJ -JM20c -Ccolor.cpt -Byafg -Bxafg --GMT_THEME=minimal

# plot colorvar with equal width
gmt colorbar -DJCB -L

gmt end show

# clean up
rm color.cpt temp.cpt

I wish there was a way to output/preserve hex values (as opposed to rgb triplets; they’re a complete pain to type and look at).

Edit: update script and figure.

I kinda like the pastel colour here. If you feel like the RGB display doesn’t render properly the hex values, have you tried the HSV system ?

Sorry - the colors render just fine. I meant how it looks in the cpt-file!

E.g.

-6000 #627890 -5000 #627890

vs.

-6000 98/120/144 -5000 98/120/144

Could you explain what the problem is? E.g., the # is assumed to mean a comment on the shell line? Might have to escape or place in single quotes etc?

No problem - just a subjective opinion that rgb triplets is a hassle to type - nothing else.

Is there any way of getting CPT tables printed with hex codes (instead of rgd or color names)?

To help you memorize some (which I can’t because I’m a pure decimal guy)

2 Likes

Seems like makecpt -F could need one more directive to do hex output - try a feature request.

1 Like