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

Function alternative_hillshade

lib/matplotlib/tests/test_colors.py:1111–1124  ·  view source on GitHub ↗
(azimuth, elev, z)

Source from the content-addressed store, hash-verified

1109 """
1110
1111 def alternative_hillshade(azimuth, elev, z):
1112 illum = _sph2cart(*_azimuth2math(azimuth, elev))
1113 illum = np.array(illum)
1114
1115 dy, dx = np.gradient(-z)
1116 dy = -dy
1117 dz = np.ones_like(dy)
1118 normals = np.dstack([dx, dy, dz])
1119 normals /= np.linalg.norm(normals, axis=2)[..., None]
1120
1121 intensity = np.tensordot(normals, illum, axes=(2, 0))
1122 intensity -= intensity.min()
1123 intensity /= np.ptp(intensity)
1124 return intensity
1125
1126 y, x = np.mgrid[5:0:-1, :5]
1127 z = -np.hypot(x - x.mean(), y - y.mean())

Callers 1

Calls 5

_sph2cartFunction · 0.85
_azimuth2mathFunction · 0.85
minMethod · 0.80
gradientMethod · 0.45
normMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…