How to change the coloured cpt file to gray coloured cpt

I am trying to make a gray color map using pygmt. While using cmap=‘dem1’ it gives me the nice coloured map with higher resolution.
Moreover while I am trying the cmap=‘gray’ it lost the resolution so i am trying to change dem1 to gray color.
However while i am changing the makecpt of dem1 as x=pygmt.makecpt(cmap=‘dem1’,series=’-1000/1000/0.1’,continuous=True) it doesnot give the gray coloured image

If anbody will suggest a better solution for the same, it will be very helpful.
My script is

fig = pygmt.Figure()
fig.basemap(region=region, projection=“M8c”, frame=[“Wsne”, “x1+lLatitude(°)”, “y1+lLongutide(°)”])
x=pygmt.makecpt(cmap=‘dem1’,series=’-1000/1000/0.1’,continuous=True)
topo_data = “@earth_relief_30s
fig.grdimage(grid=topo_data,region=region,cmap=x,projection=‘M8c’,shading=False)

Hello @seis,

to write a colormap created with pygmt.makecpt to a file you have to use the output parameter (see also pygmt.makecpt — PyGMT):

# make colormap for elevation
pygmt.makecpt(
    cmap="grayC",
    series="0/2000/10",
    continuous=True,
    output="cpt_ele.cpt",
)

Something like x = pygmt.makecpt(...) does not work. Thus, your change of the cmap parameter does not affect the colormap used by pygmt.Figure.grdimage.

o i will try and let you know

Madam, It gives the map, however in the map some portion gets gray another portion get black, can you please suggets how to make it the whole map gray color.

Probably you have to adjust the range of your colormap using the series parameter ("min/max/step") in the way that it fits the range of your elevation grid.

Maybe you can complete your posted script by providing the values of region used for your map :wink:.

1 Like