GMT Script Help - Setting White Color Transparency & Removing Text from Colorbar

Hi GMT Community,

I have been working on a GMT script and encountered a couple of issues I’m hoping someone could help me with. I’ll share the details of the issues below and would appreciate any suggestions:

  1. In my script, when I use gmt grdimage resampled_olrwodu_output.grd -Ccolors.cpt, it results in the white color from my colormap (colors.cpt) obscuring the map. Is there a way to set the white color to be transparent?

  2. Is it possible to remove the text from the colorbar?

I have included my script below for reference and am able to provide any associated files, scripts, or output figures if needed.

Here’s the script:

#!/usr/bin/env bash
# 1. Create color palette
gmt makecpt -Cseminf-haxby.cpt -T5/14 > colors.cpt

# 2. Convert data to GMT grid format
gmt xyz2grd olrwodu_output_xyz.txt -Golrwodu_output.grd -I2.5/2.5 -R70/140/15/55

# 2.1 Resample grid data with bilinear interpolation
gmt grdsample olrwodu_output.grd -Gresampled_olrwodu_output.grd -I0.025/0.025 -R70/140/15/55 -nc

# 2.1 Resample grid data with bilinear interpolation, set to 1.5 degrees interval
gmt grdsample olrwodu_output.grd -Golrwodu_output_1p5deg.grd -I1.5/1.5 -R70/140/15/55 -nc
gmt grd2xyz olrwodu_output_1p5deg.grd > olrwodu_output_points_1p5deg.txt

# 3. Generate base map
gmt begin china_map_grdsample_111
    gmt basemap -R70/140/15/55 -JM18c -Bf5a10 -BWesN
    gmt makecpt -Cetopo1 -G-11000/0
    gmt grdimage @earth_relief_03m -I

    gmt grdimage resampled_olrwodu_output.grd -Ccolors.cpt
    gmt colorbar -DjMR+w8c/0.5c+o-1c/0c -Ccolors.cpt -Bxa3f
    gmt plot olrwodu_output_points_1p5deg.txt -Sc0.1c -Gred
    gmt plot CN-border-La.gmt -W1p,-
gmt end (772 Bytes) olrwodu_output_xyz.txt (36.3 KB)

Thanks in advance for any help!


You may try -Q option of grdimage to make the background (white) transparent.