Not detecting colorbar

Hi, whenever I try to run a GMT command with colorbar, its giving me this out put. Here is my code:

#!/usr/bin/env bash



gmt makecpt -Cbathy -T-1000/0/100 -Z > def.cpt

gmt begin meshTry

gmt xyz2grd updated.txt -R-90/-50/5/40/ -I1m 

gmt grdimage -JX20c -B -Cdef.cpt  -pdf testgmtbash 

gmt colorbar -Cdef.cpt 

gmt end showS

Here is the error:

gmt.exe [ERROR]: Shared GMT module not found: colorbar

ERROR: No module named colorbar was found. This could mean one of four cases:

  1. There actually is no such module; please check your spelling.
  2. You used a modern mode module name while running in GMT classic mode.
  3. Module exists in the GMT supplemental library, but the library could not be found.
  4. Module exists in a GMT custom library, but none was specified via GMT_CUSTOM_LIBS.
    Shared libraries must be in standard system paths or set via environmental parameter %%PATH%%.

gmt.exe [ERROR]: Not available in classic mode

what do I do?

See error item number 2. colorbar is a modern mode name of a classic module called psscale. Hm, but you are running a modern mode script… Not sure why a core module is not found for you.

Hi @Roshlion,

you mixed modern mode one-liner options with regular modern mode:

Your grdimage call ends with -pdf testgmtbash which means you want the output of that command as a PDF file named testgmtbash. But you enclosed it in gmt begin … gmt end where you specify you want the output of all those commands combined in a single plot named meshTry. This can’t really work.

Try removing -pdf testgmtbash from your grdimage call and you should be fine.

@pwessel, I made this mistake myself several times after troubleshooting my scripts. When combining several steps into a complete plot I occasionally left that one-liner sytanx in place leading to the same error. Maybe a fifth error case might be a useful addition to the error message?

Some code to play with (look out for -pdf somename):

### FAILS - basemap … -pdf somename
gmt begin buffer_white png
  gmt basemap -R-24.46/-23.99/16.45/16.72 -Jm1:300000 -B \
    -B+t"S\303O NICOLAU" -pdf somename
  gmt coast -W1.13p,black
gmt end show

gmt begin buffer_white png
  gmt basemap -R-24.46/-23.99/16.45/16.72 -Jm1:300000 -B \
    -B+t"S\303O NICOLAU"
  gmt coast -W1.13p,black
gmt end show

A check for this error has now been implemented in master.

Thank you, @pwessel! Works nicely. More elegant than my suggestion.