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)
| 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``.""" |