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

Method _process_values

lib/matplotlib/colorbar.py:1076–1130  ·  view source on GitHub ↗

Set `_boundaries` and `_values` based on the self.boundaries and self.values if not None, or based on the size of the colormap and the vmin/vmax of the norm.

(self)

Source from the content-addressed store, hash-verified

1074 ax.set_subplotspec(subplotspec)
1075
1076 def _process_values(self):
1077 """
1078 Set `_boundaries` and `_values` based on the self.boundaries and
1079 self.values if not None, or based on the size of the colormap and
1080 the vmin/vmax of the norm.
1081 """
1082 if self.values is not None:
1083 # set self._boundaries from the values...
1084 self._values = np.array(self.values)
1085 if self.boundaries is None:
1086 # bracket values by 1/2 dv:
1087 b = np.zeros(len(self.values) + 1)
1088 b[1:-1] = 0.5 * (self._values[:-1] + self._values[1:])
1089 b[0] = 2.0 * b[1] - b[2]
1090 b[-1] = 2.0 * b[-2] - b[-3]
1091 self._boundaries = b
1092 return
1093 self._boundaries = np.array(self.boundaries)
1094 return
1095
1096 # otherwise values are set from the boundaries
1097 if isinstance(self.norm, colors.BoundaryNorm):
1098 b = self.norm.boundaries
1099 elif isinstance(self.norm, colors.NoNorm):
1100 # NoNorm has N blocks, so N+1 boundaries, centered on integers:
1101 b = np.arange(self.cmap.N + 1) - .5
1102 elif self.boundaries is not None:
1103 b = self.boundaries
1104 else:
1105 # otherwise make the boundaries from the size of the cmap:
1106 N = self.cmap.N + 1
1107 b, _ = self._uniform_y(N)
1108 # add extra boundaries if needed:
1109 if self._extend_lower():
1110 b = np.hstack((b[0] - 1, b))
1111 if self._extend_upper():
1112 b = np.hstack((b, b[-1] + 1))
1113
1114 # transform from 0-1 to vmin-vmax:
1115 if self.mappable.get_array() is not None:
1116 self.mappable.autoscale_None()
1117 if not self.norm.scaled():
1118 # If we still aren't scaled after autoscaling, use 0, 1 as default
1119 self.norm.vmin = 0
1120 self.norm.vmax = 1
1121 self.norm.vmin, self.norm.vmax = mtransforms._nonsingular(
1122 self.norm.vmin, self.norm.vmax, expander=0.1)
1123 if (not isinstance(self.norm, colors.BoundaryNorm) and
1124 (self.boundaries is None)):
1125 b = self.norm.inverse(b)
1126
1127 self._boundaries = np.asarray(b, dtype=float)
1128 self._values = 0.5 * (self._boundaries[:-1] + self._boundaries[1:])
1129 if isinstance(self.norm, colors.NoNorm):
1130 self._values = (self._values + 0.00001).astype(np.int16)
1131
1132 def _mesh(self):
1133 """

Callers 2

_draw_allMethod · 0.95

Calls 7

_uniform_yMethod · 0.95
_extend_lowerMethod · 0.95
_extend_upperMethod · 0.95
get_arrayMethod · 0.80
autoscale_NoneMethod · 0.45
scaledMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected