Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e08d197

Browse files
authored
disable cmap property for RGB images (#529)
1 parent a07636c commit e08d197

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fastplotlib/graphics/image.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ def __init__(
132132
self._vmin = ImageVmin(vmin)
133133
self._vmax = ImageVmax(vmax)
134134

135-
self._cmap = ImageCmap(cmap)
135+
# set cmap to None for RGB images
136+
if self._data.value.ndim == 3:
137+
self._cmap = None
138+
else:
139+
self._cmap = ImageCmap(cmap)
136140

137141
self._interpolation = ImageInterpolation(interpolation)
138142
self._cmap_interpolation = ImageCmapInterpolation(cmap_interpolation)
@@ -189,10 +193,14 @@ def data(self, data):
189193
@property
190194
def cmap(self) -> str:
191195
"""colormap name"""
196+
if self.data.value.ndim == 3:
197+
raise AttributeError("RGB images do not have a colormap property")
192198
return self._cmap.value
193199

194200
@cmap.setter
195201
def cmap(self, name: str):
202+
if self.data.value.ndim == 3:
203+
raise AttributeError("RGB images do not have a colormap property")
196204
self._cmap.set_value(self, name)
197205

198206
@property

0 commit comments

Comments
 (0)