Skip to content

Commit 4afed00

Browse files
committed
Fixed hillshading problems with masked elevation arrays
1 parent 71cb786 commit 4afed00

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/matplotlib/colors.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1696,14 +1696,22 @@ def shade_rgb(self, rgb, elevation, fraction=1., blend_mode='hsv',
16961696
'overlay': self.blend_overlay,
16971697
}
16981698
if blend_mode in lookup:
1699-
return lookup[blend_mode](rgb, intensity, **kwargs)
1699+
blend = lookup[blend_mode](rgb, intensity, **kwargs)
17001700
else:
17011701
try:
1702-
return blend_mode(rgb, intensity, **kwargs)
1702+
blend = blend_mode(rgb, intensity, **kwargs)
17031703
except TypeError:
17041704
msg = '"blend_mode" must be callable or one of {}'
17051705
raise ValueError(msg.format(lookup.keys))
17061706

1707+
# Only apply result where hillshade intensity isn't masked
1708+
if hasattr(intensity, 'mask'):
1709+
mask = intensity.mask[..., 0]
1710+
for i in range(3):
1711+
blend[..., i][mask] = rgb[..., i][mask]
1712+
1713+
return blend
1714+
17071715
def blend_hsv(self, rgb, intensity, hsv_max_sat=None, hsv_max_val=None,
17081716
hsv_min_val=None, hsv_min_sat=None):
17091717
"""

0 commit comments

Comments
 (0)