makecpt and grd2cpt overwrite explicit +c category labels with +k keys
Maintainers usually reply within 1 day
@yousizaitianqiong is already working on this.
Since Dec 4, 2026.
- #9379 by @yousizaitianqiong — open
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start by reading the -F documentation and shared helper in src/gmt_support.c, especially the label and key handling cited in the issue. Reproduce the problem with the provided makecpt command, then check the same behavior in grd2cpt. Done means +kA sets lookup keys A, B, C while the explicit labels remain Wood, Water, Gold in both commands.
Written by the indexing model from the issue text.
Description
Description of the problem
When -F+c supplies display labels and +k supplies lookup keys, the keys also replace the display labels. The one-command example from the PR that introduced +k reproduces this with an ASCII palette. Original example
Full script that reproduces the problem
gmt makecpt -Ccategorical -T0/2/1 -F+cWood,Water,Gold+kA
Actual outcome
A green L ;A
B blue L ;B
C red B ;C
N 128
The command exits 0 with empty stderr. Removing +kA writes ;Wood, ;Water and ;Gold. Removing +cWood,Water,Gold writes the keys as default labels, as expected.
Expected outcome
The first three rows should have lookup keys A, B, C and labels ;Wood, ;Water, ;Gold. The -F documentation describes these two fields separately. On master at 51117ebe, the shared helper assigns the labels and then copies each key over its label. Option documentation · Shared helper
grd2cpt shows the same behavior. The following commands produce A and B as the keys and as the labels, despite the explicit Wood and Water labels.
gmt grdmath -R0/2/0/2 -I0.5 X = grid.nc
gmt grd2cpt grid.nc -Cturbo -T0/2/1 -F+cWood,Water+kA
System information
Windows 11 x86-64, GMT 6.7.0, classic mode.
- Dominant language
- C
- Stars
- 999
- Forks
- 421
- Avg merge
- 12h 59m
- Merged PRs (30d)
- 58
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GenericMappingTools/gmt
-
Add support for SCM 9.0.0 to GMTPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
GenericMappingTools/gmt#9316 · 10 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
GenericMappingTools/gmt#5767 · 15 comments ·
Maintainers usually reply within 1 day
-
discussion
Difficulty 5/5 Over a week Newbie friendliness 35/100
GenericMappingTools/gmt#9343 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
GenericMappingTools/gmt#9331 · 1 reaction ·
Maintainers usually reply within 1 day
-
histogram: the min/max setting in -T is ignored when -R is setPossibly taken @seisman claimed this 2 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
GenericMappingTools/gmt#9330 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in GenericMappingTools/gmt
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
erkamyaman/rust-anything#1372 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
deprecation:active impact:breaking-change
Difficulty 1/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 2 days