Contour and contourf show different patterns using cartopy

Viewed 35

I'm trying to use cartopy contourf, but the pattern is wrong. Then I use cartopy contour and pcolormesh to plot the same data, and it works perfectly. Here is my python code:

v = 27.5
lev = np.arange(-v,v,2.5)
proj = ccrs.PlateCarree(central_longitude=180)
fig,axs = plt.subplots(figsize=(6,5),nrows=2,ncols=2,\
                       subplot_kw={'projection':proj})
axs = axs.flatten()
# contourf --------------------------------------
cm = axs[0].contourf(lon,lat,KE_HR_diff,cmap=cmaps.cmp_flux,\
                  levels=lev,vmin=-v,vmax=v,extend='both',\
                  transform=ccrs.PlateCarree())
axs[0].set_extent([-60,-15,10,45],crs=proj)
axs[0].coastlines(resolution='110m')
axs[0].add_feature(cart.feature.LAND,zorder=2,facecolor='#AAAAAA',edgecolor='k')
axs[0].set_title('contourf')
plt.colorbar(cm,ax=axs[0],ticks=np.arange(-25,26,10))

# contour ---------------------------------------
cm = axs[1].contour(lon,lat,KE_HR_diff,cmap=cmaps.cmp_flux,\
                  levels=lev,vmin=-v,vmax=v,extend='both',\
                  transform=ccrs.PlateCarree())
axs[1].set_extent([-60,-15,10,45],crs=proj)
axs[1].coastlines(resolution='110m')
axs[1].add_feature(cart.feature.LAND,zorder=2,facecolor='#AAAAAA',edgecolor='k')
axs[1].set_title('contour')
plt.colorbar(cm,ax=axs[1],ticks=np.arange(-25,26,10))

# pcolormesh ------------------------------------
cm = axs[2].pcolormesh(lon,lat,KE_HR_diff,cmap=cmaps.cmp_flux,\
                    vmin=-v,vmax=v,transform=ccrs.PlateCarree())
axs[2].set_extent([-60,-15,10,45],crs=proj)
axs[2].coastlines(resolution='110m')
axs[2].add_feature(cart.feature.LAND,zorder=2,facecolor='#AAAAAA',edgecolor='k')
axs[2].set_title('pcolormesh')
plt.colorbar(cm,ax=axs[2],extend='both',ticks=np.arange(-25,26,10))

axs[3].set_visible(False)
fig.savefig('KE_test.png',bbox_inches='tight')
plt.show()

enter image description here What's wrong with the contourf code?

0 Answers
Related