Skip to content

Can't change font and offset of colorbar's Y label #6799

Closed

Description

@seisman

Description of the problem

As shown below, MAP_LABLE_OFFSET and FONT_LABEL can control the X label, but have no effects on the Y label.

gmt colorbar -Cseis -Djx0c/0c+h -R0/10/0/10 -JX10c -Bxaf+l"Xaxis" -By+l"Depth" --MAP_LABEL_OFFSET=20p --FONT_LABEL=10p,1 -png map

map

System information

  • GMT version (gmt --version): 6.4.0

Activity

  1. added
    bug
    on Jun 17, 2022
  2. self-assigned this
    on Jun 17, 2022
  3. PaulWessel commented on Jun 17, 2022

    @PaulWessel
    Contributor

    True. The code shows this:

    		if (label[0]) {	/* Add label */
    			form = gmt_setfont (GMT, &GMT->current.setting.font_label);
    			gmt_map_text (GMT, xleft + 0.5 * length, y_label, &GMT->current.setting.font_label, label, 0.0, Label_justify, form);
    		}
    		if (unit[0]) {	/* Add unit label */
    			form = gmt_setfont (GMT, &GMT->current.setting.font_annot[GMT_PRIMARY]);
    
    

    So the y-label uses the annotation font as you show. I cannot see anything in the documentation that says this is how it is supposed to work, so I think we can declare a bug and change this to FONT_LABEL. Agreed? It is possible this will require updated PS files for those cases with y-labels on color bars.

  4. PaulWessel commented on Jun 18, 2022

    @PaulWessel
    Contributor

    For reference, the proposed PR makes this plot:

    map

  5. added this to the milestone on Jun 19, 2022
  6. modified the milestones: , 6.5.0 on Jun 25, 2022
  7. modified the milestones: 6.5.0, 6.6.0 on Jan 7, 2024
  8. Esteban82 commented on Aug 20, 2026

    @Esteban82
    Member

    I think this was already fixed so I will close it.

    For the record, -By+l"..." is the colorbar unit, not a label — use FONT_ANNOT_SECONDARY / MAP_ANNOT_OFFSET_SECONDARY for it, not FONT_LABEL / MAP_LABEL_OFFSET (that only affects -Bxaf+l"...").

    gmt begin test_6799 png
        gmt set FONT_LABEL 10p,1 MAP_LABEL_OFFSET 10p
        gmt set FONT_ANNOT_SECONDARY 12p,1 MAP_ANNOT_OFFSET_SECONDARY 20p
        gmt colorbar -Cseis -Dx0c/0c+w7c+h -R0/10/0/10 -JX10c -Bxaf+l"Xaxis" -By+l"Depth"
    gmt end
    
    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions