【发布时间】:2020-11-13 18:16:29
【问题描述】:
我不知道如何使用以下代码向我的 GRIB 图添加颜色条:
grib='/home/rik/hrrr/afr/vis.t20z.f00.grib2'
grbs=pygrib.open(grib)
lats, lons = grb.latlons()
map_crs = ccrs.LambertConformal(central_longitude=-100,
central_latitude=35,
standard_parallels=(30, 60))
data_crs = ccrs.PlateCarree()
fig = plt.figure(1, figsize=(14,12))
ax = plt.subplot(1, 1, 1, projection=map_crs)
ax.set_extent([-120, -75, 25, 50], data_crs)
ax.add_feature(cfeature.COASTLINE.with_scale('50m'))
ax.add_feature(cfeature.STATES.with_scale('50m'))
ax.contourf(lons, lats, grb.values, transform=data_crs)
plt.title('Surface Visibility')
plt.colorbar(grb.values, orientation='vertical')
执行上述代码后,我看到带有空垂直颜色条的绘图。我错过了什么?
【问题讨论】:
-
看看专为地理数据可视化而设计的cartopy。您还可以查看与 matplotlib 一起使用的 xarray。
标签: python matplotlib grib