Skip to content

histogram: Using a colormap to fill bars not working in case a master CPT is directly passed to -C #9314

Open

Description

@yvonnefroehlich

Description of the problem

First found in GenericMappingTools/pygmt#4988 (comment)

The histogram modul allows to color-code the bars based on the position (mid-coordinate) or the value (count or percent) of the bin (xref: https://docs.generic-mapping-tools.org/dev/histogram.html#c). However, plotting the bars with this color-coding works only in case the colormap is set up seperatly via makecpt before calling histogram. It's not correctly applied in case the colormap is directly passed to -C of histogram.

no fill constant fill position fill value fill
plot_no_fill plot_constant_fill plot_position_fill plot_value_fill
plot_position_fill_makecpt_01 plot_value_fill_makecpt_01

Full script that generated the error

gmt histogram  @v3206_06.txt -F -T250 -W0.25p -B -png plot_no_fill

gmt histogram  @v3206_06.txt -F -T250 -W0.25p -Gbisque -B -png plot_constant_fill

gmt histogram  @v3206_06.txt -F -T250 -W0.25p -Cbatlow -B -png plot_position_fill

gmt histogram  @v3206_06.txt -F -T250 -W0.25p -Cbatlow+b -B -png plot_value_fill


gmt begin plot_position_fill_makecpt
   gmt makecpt -T-7000/1000/100 -Cbatlow
   gmt histogram  @v3206_06.txt -F -T250 -W0.25p -C -B
gmt end show

gmt begin plot_value_fill_makecpt
   gmt makecpt -T-7000/1000/100 -Cbatlow
   gmt histogram  @v3206_06.txt -F -T250 -W0.25p -C+b -B
gmt end show

Full error message

No error or warning messages occur.

System information

  • Operating system: Windows
  • GMT version (gmt --version): 6.5.0 - 6.7.0_fc1ec77_2026.06.06

Activity

  1. added
    bug
    on Nov 22, 2026
  2. seisman commented on Nov 23, 2026

    @seisman
    Member

    It's not correctly applied in case the colormap is directly passed to -C of histogram.

    This statement is partially wrong. It works for a CPT passed to -C, but only if the CPT is not a master CPT.

  3. yvonnefroehlich commented on Nov 23, 2026

    @yvonnefroehlich
    MemberAuthor

    It's not correctly applied in case the colormap is directly passed to -C of histogram.

    This statement is partially wrong. It works for a CPT passed to -C, but only if the CPT is not a master CPT.

    Oh yes, that's true. If I pass a file with a colormap to -C it's working. This is something I did not check sofar.

    gmt makecpt -T-7000/1000/100 -Cbatlow > batlow_histo_position.cpt
    gmt histogram  @v3206_06.txt -F -T250 -W0.25p -Cbatlow_histo_position.cpt -B -png plot_position_fill_file
    
    gmt makecpt -T-0/1500/100 -Cbatlow > batlow_histo_value.cpt
    gmt histogram  @v3206_06.txt -F -T250 -W0.25p -Cbatlow_histo_value.cpt+b -B -png plot_value_fill_file
    fill position fill value
    plot_position_fill_file plot_value_fill_file

    I feel adding one or two sentences in the docs mentioning that master CPTs can not be used directly can avoid confusions here. In the end users need makecpt at any point to create a CPT file in the formt required for the usage in GMT.

  4. changed the title [-]histogram: Using a colormap to fill bars not working in case cmap is directly passed[/-] [+]histogram: Using a colormap to fill bars not working in case a master CPT is directly passed to -C[/+] on Nov 23, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions