matplotlib/matplotlib · error · ValueError
"blend_mode" must be callable or one of {lookup.keys}
Error message
"blend_mode" must be callable or one of {lookup.keys} What it means
Error ""blend_mode" must be callable or one of {lookup.keys}" thrown in matplotlib/matplotlib.
Source
Thrown at lib/matplotlib/colors.py:4108
An (m, n, 3) array of floats ranging between 0-1.
"""
# Calculate the "hillshade" intensity.
intensity = self.hillshade(elevation, vert_exag, dx, dy, fraction)
intensity = intensity[..., np.newaxis]
# Blend the hillshade and rgb data using the specified mode
lookup = {
'hsv': self.blend_hsv,
'soft': self.blend_soft_light,
'overlay': self.blend_overlay,
}
if blend_mode in lookup:
blend = lookup[blend_mode](rgb, intensity, **kwargs)
else:
try:
blend = blend_mode(rgb, intensity, **kwargs)
except TypeError as err:
raise ValueError('"blend_mode" must be callable or one of '
f'{lookup.keys}') from err
# Only apply result where hillshade intensity isn't masked
if np.ma.is_masked(intensity):
mask = intensity.mask[..., 0]
for i in range(3):
blend[..., i][mask] = rgb[..., i][mask]
return blend
def blend_hsv(self, rgb, intensity, hsv_max_sat=None, hsv_max_val=None,
hsv_min_val=None, hsv_min_sat=None):
"""
Take the input data array, convert to HSV values in the given colormap,
then adjust those color values to give the impression of a shaded
relief map with a specified light source. RGBA values are returned,
which can then be used to plot the shaded image with imshow.
View on GitHub (pinned to b379c1b69e)
When it happens
Trigger: Thrown at lib/matplotlib/colors.py:4108 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of matplotlib/matplotlib@b379c1b69e (2026-08-21).
Data as JSON: /api/errors/4826e36f02e6caaf.
Report an issue: GitHub.