matplotlib.colors.from_levels_and_colors#

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

一个辅助例程,用于生成与 contourf 的 levels 和 colors 参数行为类似的 cmap 和 norm 实例。

参数:
levels数字序列

用于构建 BoundaryNorm 的量化级别。如果 lev[i] <= v < lev[i+1],则值 v 被量化为级别 i

colors颜色序列

每个级别使用的填充颜色。如果 extend 为 "neither",则必须有 n_level - 1 种颜色。如果 extend 为 "min" 或 "max" 则额外添加一种颜色,如果为 "both" 则额外添加两种颜色。

extend{'neither', 'min', 'max', 'both'},可选

当值超出给定级别范围时的行为。详见 contourf

返回:
cmapColormap
normNormalize