我不得不承认我仍然无法理解绘图的正确设置和关系以及它与 matplotlib 的部分,仍然混淆 fig 与 plt 与 ax 之间的关系,所以我只是反复试验,文档有时更多让我困惑。:-(
我正在绘制来自 json 的天气值并获得积分。我可以用下面的代码绘制如下图
fig=plt.figure(figsize=(10,8))
ax=fig.add_subplot(1,1,1,projection=mapcrs)
ax.set_extent([-93,-86,13,19],datacrs)
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.BORDERS, linestyle=':')
ax.scatter(lon,lat,c=dat,transform=datacrs)
然后我使用metpy和这段代码生成插值
gridx, gridy, gridz = interpolate_to_grid(lon, lat, dat, interp_type='rbf', hres=.1, rbf_func='linear', rbf_smooth=0)
fig=plt.figure(figsize=(15,15))
ax=fig.add_subplot(1,1,1,projection=mapcrs)
#ax = fig.add_axes([0, 0, 1, 1], projection=mapcrs)
#ax.set_extent([-93,-86,13,19])
#ax.add_feature(cfeature.COASTLINE)
#ax.add_feature(cfeature.BORDERS, linestyle=':')
ax.contourf(gridx,gridy,gridz,levels=np.arange(10,60,2),cmap='viridis')
plt.plot(lon,lat,'k.',color='white')
我根据需要得到了点的插值,但无法显示特征,该怎么做?如果我取消注释 ax.extent 我看到的只是一个空白的数字。如果我取消注释 ax.features 插值显示为下图而不是地图。
感谢您的帮助和指导。