Skip to content

Annotations for categorical CPT #4388

Closed

Description

@seisman

makecpt -F+c can produce a categorical CPT, but when plotting the colorbar, the annotations look weird. See the example below. Why the annotations are "0-1", "1-2", and "2-3". Should they be "0", "1", and "2", no?

gmt begin map png
gmt basemap -R0/10/0/10 -JX4c -Baf -BWSen
gmt makecpt -Ccubhelix -T0/3/1 -F+c
gmt colorbar
gmt end show

image

Activity

  1. PaulWessel commented on Oct 27, 2020

    @PaulWessel
    Contributor

    Hm, see colorbar -Li. Seems to be doing that.

  2. seisman commented on Oct 27, 2020

    @seisman
    MemberAuthor

    colorbar -Li doesn't change anything.

  3. seisman commented on Oct 27, 2020

    @seisman
    MemberAuthor

    BTW, the categorical CPT looks correct:

    gmt makecpt -Ccubhelix -T0/3/1 -F+c
    0	24/45.5/72.5	L
    1	159.5/121/72.5	L
    2	194/215.5/242	B
    B	black
    F	white
    N	red
    
  4. PaulWessel commented on Oct 27, 2020

    @PaulWessel
    Contributor

    When colorbar plots a categorical CPT and no -B is given then it will center the annotations on each unique color and it will use as label whatever is given in the CPT (after the ; label marker per record) or, if no such labels, create one from the boundaries, i.e., 0-1, 1-2, 2-3 in your case. If I manually fix your cpt to look like this:

    0 24/45.5/72.5 L ;0
    1 159.5/121/72.5 L ;1
    2 194/215.5/242 B ;2

    then I get what you would prefer. Given this behavior is very long-lived and often reasonable, we could consider other schemes to simplify setting these labels. Here are some thoughts/suggestions for makecpt:

    Let -F+c[label] take an optional modifier argument to +c that will do the following, depending on label:

    1. If label is an integer, say 0, then we auto-add labels 0, 1, 2, ...
    2. If label is a letter (say g or G), we auto-add labels g, h, i or G, H, I
    3. If any of the above is followed by a hyphen, then we instead set labels as 0-1, 1-2, G-H, g-h, etc.
    4. If label contains a comma then we will use the comma-separated items as verbatim labels, until we run out, e.g.,
    gmt makecpt -Ccubhelix -T0/3/1 -F+c Clouds,Trees,Water
    0	24/45.5/72.5	L	;Clouds
    1	159.5/121/72.5	L	;Trees
    2	194/215.5/242	B	;Water
    

    m

    I think this is a splendid proposal no?

  5. PaulWessel commented on Oct 27, 2020

    @PaulWessel
    Contributor

    I think this possibility is a good improvement. Let me know if you agree, @joa-quim and @seisman.

  6. joa-quim commented on Oct 27, 2020

    @joa-quim
    Member

    Agree. Nice adding
    This is something we won't get easier on Julia and cousins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions