Hi,
I am new to pygmt and would like to create a single figure with two datasets plotted on top of each other: transparent (or its gradient?) topography in the background plus an xarray.DataArray on top of it using a different colormap. My aim is a figure similar to this:
I was hoping to call grdimage twice – first for topography, and a second time for plotting the xarray.DatArray. But I can only make one of both work:
My code looks like this:
fig = pygmt.Figure()
proj = 'M8i'
param = "VSV"
### PLOT 1: TOPOGRAPHY ####
# create colorbar for topo
pygmt.makecpt(
cmap='grayC', #temp 19lev
series='-200000/40000/10000',
# series='-40000/1000/1000',
continuous=True,
reverse=True,
)
fig.grdimage(
grid=topo_data,
# cmap="grayC",
region=[lon_min, lon_max,
lat_min, lat_max],
projection=proj,
# shading=True,
# frame=True,
# transparency=0.5,
shading='+a45+nt0.5', #+a45+nt1
)
### PLOT 2: VSV ####
# create colorbar for VSV
pygmt.makecpt(
cmap='polar',
series='-4/4/0.1',
continuous=True,
reverse=True,
)
## plot param values
fig.grdimage(
grid=ds, # xarray.DataArray containing VSV values
region=[lon_min, lon_max,
lat_min, lat_max],
projection=proj,
cmap=True,
frame=True,
)
# plot coastlines
fig.coast(
projection=proj,
shorelines=True,
)
# colorbar
colortext="+l\"%"+str(param)+"\""
fig.colorbar(frame=["af", colortext])
# set title
title="+t\" "+str(int(depth))+" km depth slice\""
fig.basemap(frame=["af", title])
fig.show(width=700)
Two questions:
- How can I combine both figures into one?
- Is there a better way of plotting the topography like this, that is is grdimage the best way forward here?
Thanks!