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

Method _proportional_y

lib/matplotlib/colorbar.py:1247–1283  ·  view source on GitHub ↗

Return colorbar data coordinates for the boundaries of a proportional colorbar, plus extension lengths if required:

(self)

Source from the content-addressed store, hash-verified

1245 return y, extendlength
1246
1247 def _proportional_y(self):
1248 """
1249 Return colorbar data coordinates for the boundaries of
1250 a proportional colorbar, plus extension lengths if required:
1251 """
1252 if (isinstance(self.norm, colors.BoundaryNorm) or
1253 self.boundaries is not None):
1254 y = (self._boundaries - self._boundaries[self._inside][0])
1255 y = y / (self._boundaries[self._inside][-1] -
1256 self._boundaries[self._inside][0])
1257 # need yscaled the same as the axes scale to get
1258 # the extend lengths.
1259 if self.spacing == 'uniform':
1260 yscaled = self._forward_boundaries(self._boundaries)
1261 else:
1262 yscaled = y
1263 else:
1264 y = self.norm(self._boundaries.copy())
1265 y = np.ma.filled(y, np.nan)
1266 # the norm and the scale should be the same...
1267 yscaled = y
1268 y = y[self._inside]
1269 yscaled = yscaled[self._inside]
1270 # normalize from 0..1:
1271 norm = colors.Normalize(y[0], y[-1])
1272 y = np.ma.filled(norm(y), np.nan)
1273 norm = colors.Normalize(yscaled[0], yscaled[-1])
1274 yscaled = np.ma.filled(norm(yscaled), np.nan)
1275 # make the lower and upper extend lengths proportional to the lengths
1276 # of the first and last boundary spacing (if extendfrac='auto'):
1277 automin = yscaled[1] - yscaled[0]
1278 automax = yscaled[-1] - yscaled[-2]
1279 extendlength = [0, 0]
1280 if self._extend_lower() or self._extend_upper():
1281 extendlength = self._get_extension_lengths(
1282 self.extendfrac, automin, automax, default=0.05)
1283 return y, extendlength
1284
1285 def _get_extension_lengths(self, frac, automin, automax, default=0.05):
1286 """

Callers 3

_do_extendsMethod · 0.95
_meshMethod · 0.95
__call__Method · 0.80

Calls 7

_forward_boundariesMethod · 0.95
_extend_lowerMethod · 0.95
_extend_upperMethod · 0.95
normFunction · 0.85
normMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected