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

Method _process_levels

lib/matplotlib/contour.py:1060–1095  ·  view source on GitHub ↗

Assign values to :attr:`layers` based on :attr:`levels`, adding extended layers as needed if contours are filled. For line contours, layers simply coincide with levels; a line is a thin layer. No extended levels are needed with line contours.

(self)

Source from the content-addressed store, hash-verified

1058 raise ValueError("Contour levels must be increasing")
1059
1060 def _process_levels(self):
1061 """
1062 Assign values to :attr:`layers` based on :attr:`levels`,
1063 adding extended layers as needed if contours are filled.
1064
1065 For line contours, layers simply coincide with levels;
1066 a line is a thin layer. No extended levels are needed
1067 with line contours.
1068 """
1069 # Make a private _levels to include extended regions; we
1070 # want to leave the original levels attribute unchanged.
1071 # (Colorbar needs this even for line contours.)
1072 self._levels = list(self.levels)
1073
1074 if self.logscale:
1075 lower, upper = 1e-250, 1e250
1076 else:
1077 lower, upper = -1e250, 1e250
1078
1079 if self.extend in ('both', 'min'):
1080 self._levels.insert(0, lower)
1081 if self.extend in ('both', 'max'):
1082 self._levels.append(upper)
1083 self._levels = np.asarray(self._levels)
1084
1085 if not self.filled:
1086 self.layers = self.levels
1087 return
1088
1089 # Layer values are mid-way between levels in screen space.
1090 if self.logscale:
1091 # Avoid overflow by taking sqrt before multiplying.
1092 self.layers = (np.sqrt(self._levels[:-1])
1093 * np.sqrt(self._levels[1:]))
1094 else:
1095 self.layers = 0.5 * (self._levels[:-1] + self._levels[1:])
1096
1097 def _process_colors(self):
1098 """

Callers 1

__init__Method · 0.95

Calls 1

sqrtMethod · 0.80

Tested by

no test coverage detected