In plotting the figure in the below code, I need to set the colorbar and contourf scale to a specific value range (e.g., -100 to 100). When plotting similar items, I need to ensure the scale is the same across multiple images for comparison and overide the autoscaling. Any ideas? Seems like it should be something obvious, but I’ve been chasing my tail and coming up empty. I appreciate the help!
m = Basemap(resolution=‘c’,projection=‘cyl’,llcrnrlon=lon1,llcrnrlat=lat1,\
urcrnrlon=lon2,urcrnrlat=lat2)
x,y = np.meshgrid(lon, lat)
fig1=plt.figure()
CS = m.contour(x,y,narr_totcld_summer - wwmca_totcld_summer,15,linewidths=0.5,colors=‘k’)
CS = m.contourf(x,y,narr_totcld_summer - wwmca_totcld_summer,cmap=plt.cm.jet)
#CS = m.contourf(x,y,narr_totcld_summer - wwmca_totcld_summer,cmap=plt.cm.jet, clim=[-100,100]) #didn’t work…no error but no scaling
cbar = plt.colorbar(CS, shrink=0.7, format="%1.1f", spacing=‘proportional’,orientation=‘vertical’)
m.drawcoastlines()
m.drawmapboundary()
draw parallels and meridians.
parallels = np.arange(-90,90,5)
m.drawparallels(parallels,labels=[1,0,0,1])
meridians = np.arange(0,357.5,5)
m.drawmeridians(meridians,labels=[1,0,0,1])
plt.title(‘Figure title’)
plt.show()
···
Bruce W. Ford
Clear Science, Inc.