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

Skip to content

Lightsource enhancements #3291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 29, 2014
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ee99cf5
Refactored LightSource.shade_rgb into three separate functions
joferkington Jul 21, 2014
4faa454
Added support for vertical exag and non-uniform spacing to LightSource
joferkington Jul 21, 2014
a1af495
Added new blending modes to LightSource for more realistic rendering
joferkington Jul 21, 2014
ed5cd76
Updated shading example to show new styles and added exmaple DEM from…
joferkington Jul 22, 2014
0db6341
Make the "fraction" kwarg behave as it did before recent LightSource …
joferkington Jul 23, 2014
52434ff
Strip whitespace and strict PEP8 compliance
joferkington Jul 23, 2014
108eac7
Avoid potential divide by zero in LightSource.hillshade
joferkington Jul 23, 2014
f374383
Fix calculation of aspect for hillshading.
joferkington Jul 25, 2014
3c9cacf
Make clipping work properly for effectively planar surfaces
joferkington Jul 25, 2014
51e9a6c
Added tests for LightSource functionality
joferkington Jul 26, 2014
31a4239
Added example of using the custom hillshading on a 3D surface plot
joferkington Jul 26, 2014
b3e2e3d
PEP8 fixes
joferkington Jul 26, 2014
bdbc7df
Avoid leaking file descriptors in tests and examples
joferkington Jul 26, 2014
71cb786
Added more examples
joferkington Sep 26, 2014
4afed00
Fixed hillshading problems with masked elevation arrays
joferkington Sep 27, 2014
abf8b87
Added array comparison tests for shaded relief
joferkington Sep 27, 2014
ba1f492
Strict PEP8 compliance for printed arrays
joferkington Sep 27, 2014
ab40a2f
Added *vmin* and *vmax* arguments to LightSource.shade
joferkington Sep 27, 2014
9fce26c
Added LightSource changes summary to CHANGELOG
joferkington Sep 27, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid potential divide by zero in LightSource.hillshade
  • Loading branch information
joferkington committed Jul 23, 2014
commit 108eac73ecd256cb9728d54c2593cadac31cc650
9 changes: 7 additions & 2 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,8 +1561,13 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
np.clip(intensity, imin, imax, intensity)

# Rescale to 0-1, keeping range before contrast stretch
intensity -= imin
intensity /= (imax - imin)
if imax > imin:
intensity -= imin
intensity /= (imax - imin)
else:
# If constant slope, keep relative scaling
# (i.e. flat should be 0.5, fully occluded 0, etc.)
intensity = (intensity + 1) / 2

return intensity

Expand Down