python - pcolormesh is putting out a blank map? -
i not sure doing wrong. when print map, map turns out blank? trying use pcolormesh, , think might doing wrong. 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 , 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 title, legend, , display. ax.set_title("heatmap") #setup 2d grid numpy avglonlist, avglatlist = np.meshgrid(avglonlist, avglatlist) #convert intensity (list of lists) numpy array plotting klist = np.array(klist) #now plug data pcolormesh m=plt.pcolormesh(avglonlist, avglatlist, klist) #make colorbar plt.colorbar(m) plt.clim(0.0,0.5) plt.show()
it seems missing transform in pcolormesh
. needed plots cartopy.
plt.pcolormesh(avglonlist, avglatlist, klist, transform=ccrs.platecarree())
Comments
Post a Comment