Select the starting color in the matplotlib color palette

I have a picture shown below. The colorscheme scheme currently uses the full range of the color map (mpl.cm.Paired). What I want to do, and failed to figure out, is how to limit the use of matplotlib to only a subset of the color map. In this case, I try to make the initial color a darker shade of blue. Here is a plot of my code graph:

Figure = plt.figure(figsize=(22,10))
Map    = Basemap(projection='robin', lon_0=0, resolution='l')
x, y   = Map(LONS, LATS)
levels = np.arange(0, 4100, 100)
fcp    = Map.contourf(x, y, data, levels, interpolation="bicubic", cmap=mpl.cm.Paired)

cb = Map.colorbar(fcp, "bottom", size="5%", pad='5%', extendrect=False)
cb.ax.tick_params(labelsize=18)
cb.solids.set_edgecolor("face")
cb.set_label("metres",fontsize=18)
cb.ax.set_aspect(0.047)

Map.drawcoastlines(linewidth=1)
Map.drawmapboundary(linewidth=1)
Map.drawmeridians([-150,-100,-50,0,50,100, 150],labels=[1,1,1,0],fontsize=18)
Map.drawparallels([-60,-30,0,30,60],labels=[1,1,1,1],fontsize=18)

enter image description here

0
source share
1 answer

- mpl.cm.Paired() (.. [0-1]), , , :

import matplotlib.colors as mcol

lvTmp = np.linspace(0.1,1.0,len(levels)-1)
cmTmp = mlp.cm.Paired(lvTmp)
newCmap = mcol.ListedColormap(cmTmp)

0.1 linspace, , , .

enter image description here

+7

Source: https://habr.com/ru/post/1662617/


All Articles