pcolormesh is putting out a blank map?

750 views Asked by At

I am not sure what I am doing wrong. When I print the map, the map turns out blank? I am trying to use pcolormesh, and I think I might be doing something wrong. Any suggestions?

Some sample values:

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()
1

There are 1 answers

0
ImportanceOfBeingErnest On BEST ANSWER

It seems you are missing the transform in the pcolormesh. This is generally needed for plots with cartopy.

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