Nearside Perspective projection missing data contourf plot

352 Views Asked by At
def plotMap():
        
    proj=ccrs.NearsidePerspective(central_longitude=270, central_latitude=80)
    fig, ax = plt.subplots(subplot_kw=dict(projection=proj), figsize=(12,10))
    #ax.set_extent([-179, 179, 20, 90], crs=ccrs.PlateCarree())
    
    ax.add_feature(cfeature.OCEAN.with_scale('10m'), facecolor='black',  zorder=12)
    ax.add_feature(cfeature.LAKES.with_scale('50m'), facecolor='black',  zorder=12)  
    ax.add_feature(cfeature.BORDERS.with_scale('10m'), zorder=10)
    ax.add_feature(cfeature.COASTLINE.with_scale('10m'), zorder=13)
  

    states_provinces = cfeature.NaturalEarthFeature(
            category='cultural',  name='admin_1_states_provinces_lines',
            scale='50m', facecolor='none', linewidth=1.2)
    ax.add_feature(states_provinces, edgecolor='gray', zorder=15)
    
    return fig, ax 

fig, ax = plotMap()
cmap=my_cmap1
levels= [-48,-36,-24,-18,-12,-9,-6,-4,-2,2,4,6,9,12,18,24,36,48]
tick_labels = ['-4ft \n -1220mm','-3ft \n -905mm','-2ft \n -610mm','-1.5ft \n -457mm','-1ft \n -305mm','-9in \n -229mm','-6in \n -152mm','-4in \n -102mm','-2in \n -51mm',
                   '+2in \n +51mm','4in \n 102mm','+6in \n +152mm','+9in \n +229mm','+1ft \n +305mm','+1.5ft \n +457mm','+2ft \n +610mm','+3ft \n +905mm','+4ft \n +1220mm']
ticks=levels
contourf = ax.contourf(wrap_lons,lat, lanina_snow_anom_final, levels=levels, cmap=cmap, extend='both', zorder=1.1, transform = ccrs.PlateCarree())
cb = plt.colorbar(contourf, pad=0.01, orientation='horizontal', aspect=30, ticks=ticks)
cb.ax.tick_params(labelsize=13)
cb.ax.set_xlabel('Snowfall Anom', weight='bold')
cb.ax.set_xticklabels(tick_labels, fontsize=8)
cb.outline.set_edgecolor('black')

plt.title('Composite Snowfall Anom DJF 2005-06, 2007-08, 2010-11, 2016-17', fontsize=16, weight='bold')
plt.savefig('/root/research_imgs/winter_2020/laninas_snow_anom_NH', dpi=150, bbox_inches="tight")
plt.close()

Results in this plot: enter image description here

Why are only the positive values plotted? I don't understand what is happening here. The same thing happens if I specify the central longitude as -90.

1

There are 1 best solutions below

0
On

This is actually an ongoing issue in Cartopy. Negative values do not appear for certain fields and projections when plotting with contourf. Try using pcolormesh with Cartopy or contourf with Basemap.