Create histogram with color bar based on CPT

I want to create a global hypsometry curve (like Fig 9a of Tozer 2019).

I try the following commands. With -Gred the figure is Ok. Then I try the other two options but I couldn’t. What I am doing wrong?

  	gmt grd2xyz @earth_relief_01d_p > "datos" -o2

  	gmt pshistogram -R-11000/8500/0/4.5 -JX10c/5c "datos" -Gred -A -T100 -Z1 -Baf -K > 

  	gmt makecpt -Cglobe -T-11000/8500 >  color.cpt
  	gmt pshistogram -R -J "datos" -Ccolor.cpt  -A -T100 -Z1 -Baf -O -K >> -Vi -Y5.5c
  	gmt pshistogram -R -J "datos" -Cglobe      -A -T100 -Z1 -Baf -O >> -Vi -Y5.5c

  	gmt psconvert -A -Tg -Z

GMT version: Version 6.2.0_e752793-dirty_2021.02.22

Have you tried to hard write the cpt ? (makecpt [...] -H)

I think there are two problems.

  • The -C cpt info says it should be in the units produced by the -Z option but you are using the original meters of the raw data
  • You are not making any allowance for the fact that grid nodes at higher latitudes represent less area than those at lower latitude. Use grd2xyz -Wa and +w in the histogram -Z option.

Hi Gus.Thanks but -H is for modern mode. I am using classic.

Hi Paul.
I had the -Wa option but I removed to see where is the problem. I will check the other option. I think that only could explain the upper graph.

For the middle graph I use makecpt to change the values.

However, I managed to get the image with the same code but in GMT6.1.1 (win64). So I suspect that there ir a bug in 6.2. I will check again.

We need a way to select either bin value or bin index to drive the color. I remember talking with @Joaquim but I did not implement. Given 6.1.1 the default should stay as that and then another switch or modifier selects bin index cpt

It seems it was modified here (#4373 and #4292). It was proposed: “Add modifier +b to -C when we want the CPT to apply to the bin’s x-value instead” but at the end it wasn’t implement it.

Hmm vague memory. Was that during the discussion about pshistogram slowness?

I could not find it there but I did not make a separate issue of this. So I think I just need to fix this via a modifier. OPtions are

  1. Add a +b or similar to -Ccpt to say use colors with the index (bin) values
  2. Add a new option (only one left is -M) to do the same

I think +b is better, no?

1 Like

Now implemented and merged to master.

1 Like

Thanks Paul.

For the record, it was fixed in GMT6.2 and now this works:

  	gmt makecpt -Cglobe -T-11000/8500 >  color.cpt
  	gmt pshistogram  -R-11000/8500/0/4.5 -JX10c/5c "datos" -Ccolor.cpt  -A -T100 -Z1 -Baf >