import xarray as xr
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import numpy as np
tif1 = r'.tif'
data = xr.open_dataarray(tif1)
fig = plt.figure(figsize=(5,5))
ax11 = fig.add_axes([0.05,0.05,0.4,0.42], projection =ccrs.PlateCarree())
trend = data[0].plot.imshow(ax=ax11,cmap='RdYlGn',add_colorbar=False,
transform=ccrs.PlateCarree(),
vmax=1,vmin=-1,
zorder=1)
#0.26为一个阈值,根据自己的需求设置即可
dot_area = np.asarray(np.abs(data.values)>0.26).reshape(279,618) #279,618 矩阵行列号
mesh_lon, mesh_lat = np.meshgrid(data['x'], data['y'])
ax11.scatter(mesh_lon[dot_area],mesh_lat[dot_area],transform=ccrs.PlateCarree(), color='k',marker='x',s=0.05,linewidth=0.1,zorder=2)
ax11.set_title('')
plt.show()
Python cartopy 绘图 显著性打点
于 2022-07-24 17:33:20 首次发布