python - Matplotlib- How to make color fill bias towards max & min values? -


the issue

i have plot of correlation of 2 variables of values close either -1 or 1. i'm using seismic colormap (red & blue w/ white in middle), of plot either dark blue (close -1) or dark red (close 1), showing little detail near min & max values.

the code

here's code block used plotting.

#set variables lonlabels = ['0','45e','90e','135e','180','135w','90w','45w','0'] latlabels = ['90s','60s','30s','eq.','30n','60n','90n'] bounds = np.array([-1.0,-0.8,-0.6,-0.4,-0.2,0,0.2,0.4,0.6,0.8,1.0])  #create basemap fig,ax = plt.subplots(figsize=(15.,10.)) m = basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90,llcrnrlon=0,urcrnrlon=360.,lon_0=180.,resolution='c') m.drawcoastlines(linewidth=1,color='w') m.drawcountries(linewidth=1,color='w') m.drawparallels(np.arange(-90,90,30.),linewidth=0.3) m.drawmeridians(np.arange(-180.,180.,45.),linewidth=0.3)    meshlon,meshlat = np.meshgrid(lon,lat) x,y = m(meshlon,meshlat)  #plot variable corre = m.pcolormesh(x,y,corrcoef,cmap='seismic', shading='gouraud',vmin=-1.0,vmax=1.0)  #set titles & labels #colorbar cbar = m.colorbar(corre,size="8%",ticks=bounds,location='bottom',pad=0.8) cbar.set_label(label='correlation coefficient',size=25) cbar.set_ticklabels(bounds) t in cbar.ax.get_xticklabels():      t.set_fontsize(25) #titles fig.suptitle('correlation of local precipitation global (canesm2)',fontsize=30,x=0.51,y=0.92) ax.set_xlabel('longitude',fontsize=25) ax.set_xticks(np.arange(0,  405,45)) ax.set_xticklabels(lonlabels,fontsize=20) ax.set_ylabel('latitude', fontsize=25) ax.set_yticks(np.arange(-90,120,30)) ax.set_yticklabels(latlabels,fontsize=20) 

and here's plot generates.

enter image description here

the question

i'd adjust color fill scheme middle portion of colormap, -0.9 0.9 range, compacted (almost break not quite) , color fill better defines values @ ends. how can that? symmetric logarithmic distribution, biased towards max & min instead of middle value.

there keyword argument norm can use pcolormesh in order change scale of color mapping. take @ matplotlib documentation this. , can use parameter linthresh change middle range. haven't tried think might solve problem.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -