Parameters ---------- name : str The name of the colormap. N : int The number of RGB quantization levels. bad : :mpltype:`color`, default: transparent The color for invalid values (NaN or masked). .. versionadd
(self, name, N=256, *, bad=None, under=None, over=None)
| 715 | """ |
| 716 | |
| 717 | def __init__(self, name, N=256, *, bad=None, under=None, over=None): |
| 718 | """ |
| 719 | Parameters |
| 720 | ---------- |
| 721 | name : str |
| 722 | The name of the colormap. |
| 723 | N : int |
| 724 | The number of RGB quantization levels. |
| 725 | bad : :mpltype:`color`, default: transparent |
| 726 | The color for invalid values (NaN or masked). |
| 727 | |
| 728 | .. versionadded:: 3.11 |
| 729 | |
| 730 | under : :mpltype:`color`, default: color of the lowest value |
| 731 | The color for low out-of-range values. |
| 732 | |
| 733 | .. versionadded:: 3.11 |
| 734 | |
| 735 | over : :mpltype:`color`, default: color of the highest value |
| 736 | The color for high out-of-range values. |
| 737 | |
| 738 | .. versionadded:: 3.11 |
| 739 | """ |
| 740 | self.name = name |
| 741 | self.N = int(N) # ensure that N is always int |
| 742 | self._rgba_bad = (0.0, 0.0, 0.0, 0.0) if bad is None else to_rgba(bad) |
| 743 | self._rgba_under = None if under is None else to_rgba(under) |
| 744 | self._rgba_over = None if over is None else to_rgba(over) |
| 745 | self._i_under = self.N |
| 746 | self._i_over = self.N + 1 |
| 747 | self._i_bad = self.N + 2 |
| 748 | self._isinit = False |
| 749 | self.n_variates = 1 |
| 750 | #: When this colormap exists on a scalar mappable and colorbar_extend |
| 751 | #: is not False, colorbar creation will pick up ``colorbar_extend`` as |
| 752 | #: the default value for the ``extend`` keyword in the |
| 753 | #: `matplotlib.colorbar.Colorbar` constructor. |
| 754 | self.colorbar_extend = False |
| 755 | |
| 756 | def __call__(self, X, alpha=None, bytes=False): |
| 757 | r""" |