matplotlib.colors.from_levels_and_colors#

matplotlib.colors.from_levels_and_colors(levels,colors,extend='neither')[source]#

A helper routine to generate a cmap and a norm instance whichbehave similar to contourf's levels and colors arguments.

Parameters:
levelssequence of numbers

The quantization levels used to construct theBoundaryNorm.Valuev is quantized to leveli iflev[i]<=v<lev[i+1].

colorssequence of colors

The fill color to use for each level. Ifextend is "neither" theremust ben_level-1 colors. For anextend of "min" or "max" addone extra color, and for anextend of "both" add two colors.

extend{'neither', 'min', 'max', 'both'}, optional

The behaviour when a value falls out of range of the given levels.Seecontourf for details.

Returns:
cmapColormap
normNormalize