Hello, PyGMT community. How can I use pygmt.grdimage to plot only the ‘ones’ from an xarray dataset with a specific color (e.g., green) while making the ‘zeros’ areas transparent? I’ve already tried setting the zeros as np.NaN and using nan_transparent=True, as well as experimenting with bit_color=‘green+f’, but the desired effect isn’t being achieved. Could someone provide guidance on how to modify my code to achieve this visualization?
import numpy as np
import xarray as xr
import pygmt
# Create a random 100x100 array with 0s and 1s
random_data = np.random.randint(2, size=(100, 100))
# Create an xarray dataset from the random array
dims = ('x', 'y')
coords = {'x': np.arange(100), 'y': np.arange(100)}
data_array = xr.DataArray(random_data, dims=dims, coords=coords)
dataset = xr.Dataset({'data': data_array})
fig = pygmt.Figure()
fig.grdimage(grid=dataset.data, projection='X20c')
fig.show()
Thank you in advance,
Robson