How to use more than one colormaps in one plot?

I want to plot the land and ocean using different colormaps (geo and topo, respectively). Right now, the system will automatically use the later colormap for both of the regions.

Is there a way I could address this issue? Many thanks!

The cleanest way is to plot using one colormap, then use coast to setup a clip path for the other area and plot again with the second colormap, then undo the clip path.
But as you know, this is already shown in gallery example 17.

1 Like

Many thanks, Paul. I just tried and it works great!

Is there an easy way to do this in the Python implementation of GMT? Trying to do something similar where topography in the ocean is highlighted with the geo colormap but topography on land is depicted with the gray colormap, since I am overlaying it with other layers. I figured out how to plot with just different solid colors, but can’t seem to get things working with 2 colormaps. Thank you!

You could try to create a new cpt from the 2 masters cpt.

In bash I do it with this:

gmt makecpt -Cbathy -T-12000/0 -N -H >  new_cpt
gmt makecpt -Cgray  -T0/9000   -I -H >> new_cpt

Here you can see some maps that I created:

1 Like

Thanks for the tip, Esteban. I am looking in the Python documentation to see how to translate this there, but the pygmt.makecpt documentation seems to be a bit more lacking and I can’t quite figure out how to combine two colormaps. I’d greatly appreciate if anyone has tips on how to implement this in Python! Thank you!