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

Method __getitem__

lib/matplotlib/colors.py:2093–2118  ·  view source on GitHub ↗

Creates and returns a colorbar along the selected axis

(self, item)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

_initMethod · 0.95
ListedColormapClass · 0.85

Tested by

no test coverage detected