我正在使用以下代码在地图上绘制数据:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from mpl_toolkits.basemap import Basemap
from matplotlib.patches import Polygon
from scipy.io import netcdf
ncfile = netcdf.netcdf_file(myfile.nc,'r')
lon = ncfile.variables['longitude'][:]
lat = ncfile.variables['latitude'][:]
data = ncfile.variables['mydata'][:]
ncfile.close()
m = Basemap(projection='nplaea', boundinglat=40, lon_0=270)
m.drawcoastlines(linewidth=.6, zorder=2)
m.drawparallels(np.arange(-80.,81.,20.), zorder=1)
m.drawmeridians(np.arange(-180.,181.,20.), zorder=1)
cNorm = mpl.colors.Normalize(vmin=0, vmax=np.nanmax(data))
cmap = plt.get_cmap('jet')
lons, lats = np.meshgrid(lon, lat)
x, y = m(lons, lats)
datamap = m.pcolor(x, y, data, zorder=0)
datamap.set_norm(cNorm)
plt.colorbar(datamap, cmap=cmap, norm=cNorm, shrink=0.5)
plt.savefig('figures/map_polar.png', dpi=150, bbox_inches='tight', pad_inches=0.4)
这导致了这个图像:
如您所见,网格单元之间存在白色间隙。我怎样才能摆脱它们?