pcolormesh 正在推出一张空白地图?
pcolormesh is putting out a blank map?
我不确定我做错了什么。当我打印地图时,地图变成空白?我正在尝试使用 pcolormesh,我想我可能做错了什么。有什么建议吗?
一些示例值:
avglonlist=[-63.414436532479854, -63.41382404937334, -63.41320293629234, -63.4126322428388, -63.412060546875, -63.41134304470493]
avglatlist=[44.5523500343606, 44.55130764100617, 44.550250391568596, 44.54927937825529, 44.54830612909229, 44.5470865885415]
klist=['0.1243', '0.1304', '0.1321', '0.1281', '0.1358', '0.1105']
crs_latlon = ccrs.PlateCarree()
def make_plotmesh(projection_name, projection_crs,avglonlist, avglatlist,klist):
ax = plt.axes(projection=projection_crs)
#ax.set_extent((-65.0, -58, 40, 47.7), crs=crs_latlon)
ax.set_extent((-64.0, -61, 42.5, 45.0), crs=crs_latlon)
#Add coastlines and meridians/parallels (Cartopy-specific).
plt.gca().coastlines('10m')
gl=ax.gridlines(crs=crs_latlon, draw_labels=True,
linewidth=1, color='gray', alpha=0.5, linestyle='-')
gl.xlabels_top = False
gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
# Add a title, legend, and display.
ax.set_title("HEATMAP")
#setup the 2D grid with Numpy
avglonlist, avglatlist = np.meshgrid(avglonlist, avglatlist)
#convert intensity (list of lists) to a numpy array for plotting
klist = np.array(klist)
#now just plug the data into pcolormesh
m=plt.pcolormesh(avglonlist, avglatlist, klist)
#make colorbar
plt.colorbar(m)
plt.clim(0.0,0.5)
plt.show()
您似乎缺少 pcolormesh
中的转换。这通常是带有 cartopy 的地块所需要的。
plt.pcolormesh(avglonlist, avglatlist, klist, transform=ccrs.PlateCarree())
我不确定我做错了什么。当我打印地图时,地图变成空白?我正在尝试使用 pcolormesh,我想我可能做错了什么。有什么建议吗?
一些示例值:
avglonlist=[-63.414436532479854, -63.41382404937334, -63.41320293629234, -63.4126322428388, -63.412060546875, -63.41134304470493]
avglatlist=[44.5523500343606, 44.55130764100617, 44.550250391568596, 44.54927937825529, 44.54830612909229, 44.5470865885415]
klist=['0.1243', '0.1304', '0.1321', '0.1281', '0.1358', '0.1105']
crs_latlon = ccrs.PlateCarree()
def make_plotmesh(projection_name, projection_crs,avglonlist, avglatlist,klist):
ax = plt.axes(projection=projection_crs)
#ax.set_extent((-65.0, -58, 40, 47.7), crs=crs_latlon)
ax.set_extent((-64.0, -61, 42.5, 45.0), crs=crs_latlon)
#Add coastlines and meridians/parallels (Cartopy-specific).
plt.gca().coastlines('10m')
gl=ax.gridlines(crs=crs_latlon, draw_labels=True,
linewidth=1, color='gray', alpha=0.5, linestyle='-')
gl.xlabels_top = False
gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
# Add a title, legend, and display.
ax.set_title("HEATMAP")
#setup the 2D grid with Numpy
avglonlist, avglatlist = np.meshgrid(avglonlist, avglatlist)
#convert intensity (list of lists) to a numpy array for plotting
klist = np.array(klist)
#now just plug the data into pcolormesh
m=plt.pcolormesh(avglonlist, avglatlist, klist)
#make colorbar
plt.colorbar(m)
plt.clim(0.0,0.5)
plt.show()
您似乎缺少 pcolormesh
中的转换。这通常是带有 cartopy 的地块所需要的。
plt.pcolormesh(avglonlist, avglatlist, klist, transform=ccrs.PlateCarree())