咔嗒倒钩不能正常工作

时间:2018-04-12 00:21:51

标签: python matplotlib cartopy

我试图在北太平洋投影上绘制250 hPa的位势高度,1000 hPa的可降水量和250 hPa的风。当尝试使用倒钩时,我不会收到错误,但倒钩不会在地图上显示出来。我认为这可能与将我的数据投影到纸板投影上有关,但我对纸板很新,并且不太了解发生了什么。如果有人注意到我的预测一般都搞砸了,我就不会介意一些方向。谢谢!

def plotMap():

    proj = ccrs.LambertConformal(central_longitude=-165, central_latitude=30, standard_parallels=[53])

    fig, ax = plt.subplots(subplot_kw=dict(projection=proj))   

    ax.set_extent([235 ,160 , 5, 60], crs=ccrs.PlateCarree())    
    ax.add_feature(cfeature.LAND, facecolor='0.9') 
    ax.add_feature(cfeature.LAKES, alpha=0.9)  
    ax.add_feature(cfeature.BORDERS, zorder=10)
    ax.add_feature(cfeature.COASTLINE, zorder=10)

    states_provinces = cfeature.NaturalEarthFeature(category='cultural',  
    name='admin_1_states_provinces_lines', scale='50m', facecolor='none')

    ax.add_feature(states_provinces, edgecolor='gray', zorder=10)

    ax.gridlines(xlocs=np.arange(0,361,20), ylocs=np.arange(-80,90,20)) 

    return fig, ax

fig, ax = plotMap()




hght_levels = np.arange(9500,11250,250)
hght_contour=ax.contour(lon, lat, g, colors='k', levels=hght_levels, 
linewidths=1, zorder=3, transform = ccrs.PlateCarree())

wind_levels = np.arange(0, 110, 10)
wind_contour = ax.contour(lon, lat, wind, levels = wind_levels, 
linewidths=5, zorder=0.8, transform = ccrs.PlateCarree())

pwat_levels = np.linspace(0, 50, 9)
pwat_contour = ax.contourf(lon, lat, pwat, levels = pwat_levels,  
                       cmap=plt.cm.plasma, zorder=1.0, transform = 
ccrs.PlateCarree())
cb = plt.colorbar(pwat_contour, shrink=0.5)
cb.set_ticklabels(pwat_levels)

urel = u.values*1.944
vrel = v.values*1.944
ax.barbs(lon, lat, urel, vrel, regrid_shape=12 transform=ccrs.LambertConformal())

plt.clabel(hght_contour, hght_levels, zorder=20, inline=1,inline_spacing=3, 
fmt='%1i', fontsize=12)


fig

The plot

enter image description here

1 个答案:

答案 0 :(得分:0)

您对通话barbs的预测会将transform参数设为LambertConformal(),但看起来您正在传递位置的纬度和经度值。正如您在其他绘图方法中使用的那样,将transform更改为PlateCarree()