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

Method with_alpha

lib/matplotlib/colors.py:958–974  ·  view source on GitHub ↗

Return a copy of the colormap with a new uniform transparency. Parameters ---------- alpha : float The alpha blending value, between 0 (transparent) and 1 (opaque).

(self, alpha)

Source from the content-addressed store, hash-verified

956 self._lut[self._i_bad] = self._rgba_bad
957
958 def with_alpha(self, alpha):
959 """
960 Return a copy of the colormap with a new uniform transparency.
961
962 Parameters
963 ----------
964 alpha : float
965 The alpha blending value, between 0 (transparent) and 1 (opaque).
966 """
967 if not isinstance(alpha, Real):
968 raise TypeError(f"'alpha' must be numeric or None, not {type(alpha)}")
969 if not 0 <= alpha <= 1:
970 raise ValueError("'alpha' must be between 0 and 1, inclusive")
971 new_cm = self.copy()
972 new_cm._ensure_inited()
973 new_cm._lut[:, 3] = alpha
974 return new_cm
975
976 def _init(self):
977 """Generate the lookup table, ``self._lut``."""

Callers 2

test_contour_hatchingFunction · 0.80
test_colormap_with_alphaFunction · 0.80

Calls 2

copyMethod · 0.95
_ensure_initedMethod · 0.80

Tested by 2

test_contour_hatchingFunction · 0.64
test_colormap_with_alphaFunction · 0.64