Nice, that visual plot does look pretty good!
About changing the grdimage colour, what you want is a discrete or categorical color palette table (CPT). Have a look at using pygmt.makecpt
or pygmt.grd2cpt
to produce a CPT, and here’s some code to get started:
fig = pygmt.Figure()
pygmt.makecpt(cmap="categorical", series=(0, 8, 1), color_model="+c")
fig.grdimage(grid=ds, cmap=True, projection="M10c", frame=True)
fig.show()
You might have to manually tweak things to get the exact colour order you want (e.g. 1=red, 2=blue, etc). For that, you can use pygmt.makecpt(..., output="custom.cpt")
, open up that ‘custom.cpt’ file in a text editor and change the colours accordingly. Afterwards, use fig.grdimage(..., cmap="custom.cpt", ...)
and see how things look on the map.
Jumping ahead, if you want to plot the centroids with the same colour, you might find the gallery example at https://www.pygmt.org/v0.3.1/gallery/symbols/points_categorical.html to be useful, as it is about plotting points with different colours according to categories. Let us know if you get confused about anything, making a CPT can be quite tricky sometimes!