MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _process_colors

Method _process_colors

lib/matplotlib/contour.py:1097–1139  ·  view source on GitHub ↗

Color argument processing for contouring. Note that we base the colormapping on the contour levels and layers, not on the actual range of the Z values. This means we don't have to worry about bad values in Z, and we always have the full dynamic range availa

(self)

Source from the content-addressed store, hash-verified

1095 self.layers = 0.5 * (self._levels[:-1] + self._levels[1:])
1096
1097 def _process_colors(self):
1098 """
1099 Color argument processing for contouring.
1100
1101 Note that we base the colormapping on the contour levels
1102 and layers, not on the actual range of the Z values. This
1103 means we don't have to worry about bad values in Z, and we
1104 always have the full dynamic range available for the selected
1105 levels.
1106
1107 The color is based on the midpoint of the layer, except for
1108 extended end layers. By default, the norm vmin and vmax
1109 are the extreme values of the non-extended levels. Hence,
1110 the layer color extremes are not the extreme values of
1111 the colormap itself, but approach those values as the number
1112 of levels increases. An advantage of this scheme is that
1113 line contours, when added to filled contours, take on
1114 colors that are consistent with those of the filled regions;
1115 for example, a contour line on the boundary between two
1116 regions will have a color intermediate between those
1117 of the regions.
1118
1119 """
1120 self.monochrome = self.cmap.monochrome
1121 if self.colors is not None:
1122 # Generate integers for direct indexing.
1123 i0, i1 = 0, len(self.levels)
1124 if self.filled:
1125 i1 -= 1
1126 # Out of range indices for over and under:
1127 if self.extend in ('both', 'min'):
1128 i0 -= 1
1129 if self.extend in ('both', 'max'):
1130 i1 += 1
1131 self.cvalues = list(range(i0, i1))
1132 self.set_norm(mcolors.NoNorm())
1133 else:
1134 self.cvalues = self.layers
1135 self.norm.autoscale_None(self.levels)
1136 self.set_array(self.cvalues)
1137 self.update_scalarmappable()
1138 if self.extend in ('both', 'max', 'min'):
1139 self.norm.clip = False
1140
1141 def _process_linewidths(self, linewidths):
1142 Nlev = len(self.levels)

Callers 2

__init__Method · 0.95
changedMethod · 0.95

Calls 4

update_scalarmappableMethod · 0.80
set_normMethod · 0.45
autoscale_NoneMethod · 0.45
set_arrayMethod · 0.45

Tested by

no test coverage detected