I try to hatch only the regions where I have statistically significant results. How can I do this using Basemap and pcolormesh?
plt.figure(figsize=(12,12))
lons = iris_cube.coord('longitude').points
lats = iris_cube.coord('latitude').points
m = Basemap(llcrnrlon=lons[0], llcrnrlat=lats[0], urcrnrlon=lons[-1], urcrnrlat=lats[-1], resolution='l')
lon, lat = np.meshgrid(lons, lats)
plt.subplot(111)
cs = m.pcolormesh(lon, lat, significant_data, cmap=cmap, norm=norm, hatch='/')


It seems
pcolormeshdoes not support hatching (see https://github.com/matplotlib/matplotlib/issues/3058). Instead, the advice is to usepcolor, which starting from this example would look like,where a mask array is used to get the values of z greater than 0.3 and these are hatched using
pcolor.To avoid plotting another colour over the top (so you get only hatching) I've set alpha to 0. in
pcolorwhich feels a bit like a hack. The alternative is to use patch and assign to the areas you want. See this example Python: Leave Numpy NaN values from matplotlib heatmap and its legend. This may be more tricky for basemaps, etc than just choosing areas withpcolor.