问题描述
我看过示例,但是我不确定我是否了解如何使用matplotlib裁剪或删除不需要的轮廓填充数据绘图。我有以下代码,它为西班牙生成了轮廓填充数据的地图。我需要删除西班牙国家/地区边界之外的轮廓填充数据。非常感谢您的帮助!
#The easiest way to read the data is:
path = "//porfiler03/gtdshare/VORTEX/ESP.Spain.Main.nc"
DSC = xr.open_mfdataset(path,combine='nested',concat_dim='time')
damc = DSC.M
lats = damc['lat'].data
lons = damc['lon'].data
Now = datetime.datetime.Now()
currm = Now.month
import calendar
import cartopy
#plot data
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines(lw=1)
ax.add_feature(cartopy.feature.BORDERS,linestyle='-',alpha=.5)
damc = damc.squeeze()
clevs = np.linspace(-30.,30.,20)
cnplot = plt.contourf(lons,lats,damc,clevs,add_labels=True,cmap='jet')
cbar = plt.colorbar(cnplot)
cbar.set_label('Anomaly %')
plt.title('Wind Speed Anomaly {} 2020'.format(calendar.month_name[currm-1]))
plt.show()
上面的代码产生下面的图像,但是在这种情况下,我需要删除西班牙国家/地区边界之外的轮廓数据。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)