我不确定自己在做什么错。当我打印地图时,地图变成空白?我正在尝试使用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中的转换。对于具有羧基的地块,通常需要这样做。

plt.pcolormesh(avglonlist, avglatlist, klist, transform=ccrs.PlateCarree())

关于python - pcolormesh正在推出一张空白 map ?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46145444/

10-12 03:51