Creates and returns a colorbar along the selected axis
(self, item)
| 2091 | X[1][mask_outside] = -1 |
| 2092 | |
| 2093 | def __getitem__(self, item): |
| 2094 | """Creates and returns a colorbar along the selected axis""" |
| 2095 | if not self._isinit: |
| 2096 | self._init() |
| 2097 | extremes = ( |
| 2098 | dict(bad=self._rgba_bad, over=self._rgba_outside, under=self._rgba_outside) |
| 2099 | if self.shape in ['ignore', 'circleignore'] |
| 2100 | else dict(bad=self._rgba_bad) |
| 2101 | ) |
| 2102 | if item == 0: |
| 2103 | origin_1_as_int = int(self._origin[1]*self.M) |
| 2104 | if origin_1_as_int > self.M-1: |
| 2105 | origin_1_as_int = self.M-1 |
| 2106 | one_d_lut = self._lut[:, origin_1_as_int] |
| 2107 | new_cmap = ListedColormap(one_d_lut, name=f'{self.name}_0', **extremes) |
| 2108 | |
| 2109 | elif item == 1: |
| 2110 | origin_0_as_int = int(self._origin[0]*self.N) |
| 2111 | if origin_0_as_int > self.N-1: |
| 2112 | origin_0_as_int = self.N-1 |
| 2113 | one_d_lut = self._lut[origin_0_as_int, :] |
| 2114 | new_cmap = ListedColormap(one_d_lut, name=f'{self.name}_1', **extremes) |
| 2115 | else: |
| 2116 | raise KeyError(f"only 0 or 1 are" |
| 2117 | f" valid keys for BivarColormap, not {item!r}") |
| 2118 | return new_cmap |
| 2119 | |
| 2120 | def _repr_png_(self): |
| 2121 | """Generate a PNG representation of the BivarColormap.""" |
nothing calls this directly
no test coverage detected