René's URL Explorer Experiment


Title: Lightsource enhancements by joferkington · Pull Request #3291 · matplotlib/matplotlib · GitHub

Open Graph Title: Lightsource enhancements by joferkington · Pull Request #3291 · matplotlib/matplotlib

X Title: Lightsource enhancements by joferkington · Pull Request #3291 · matplotlib/matplotlib

Description: Currently, colors.LightSource preforms "hillshading" through methods that appear visually unrealistic in some cases (particularly topographic surfaces). This pull request: Refactors LightSource to allow the hillshade method to be called independently so that illumination maps can be produced. Adds support for common parameters such as vertical exaggeration and x/y spacing so that topographically accurate illumination can be calculated. (Or so that the effect of topography can be exaggerated or subdued in the final result.) Adds support for multiple blend modes to combine the illumination map with the rgb data. blend_mode='overlay' and blend_mode='soft' are both more visually appealing for complex surfaces than the default mode. Effectively, the other blend modes make the surface appear less "shiny". All of the changes made should be fully backwards-compatible and none of the defaults have been changed. This also adds a 170Kb example data file of some SRTM elevation data (public domain) to the sample data. As a quick example of the effect of some of the changes: import numpy as np import matplotlib.pyplot as plt from matplotlib.cbook import get_sample_data from matplotlib.colors import LightSource dem = np.load(get_sample_data('jacksboro_fault_dem.npz')) z = dem['elevation'] # Shade from the northwest, with the sun 45 degrees from horizontal ls = LightSource(azdeg=315, altdeg=45) cmap = plt.cm.gist_earth fig, axes = plt.subplots(nrows=4, ncols=3, figsize=(8, 9)) plt.setp(axes.flat, xticks=[], yticks=[]) # Vary vertical exaggeration and blend mode and plot all combinations for col, ve in zip(axes.T, [0.01, 0.1, 10]): # Show the hillshade intensity image for each vert. exag. col[0].imshow(ls.hillshade(z, vert_exag=ve), cmap='gray') for ax, mode in zip(col[1:], ['hsv', 'overlay', 'soft']): rgb = ls.shade(z, cmap=cmap, vert_exag=ve, blend_mode=mode) ax.imshow(rgb) # Label rows and columns for ax, ve in zip(axes[0], [0.01, 0.1, 10]): ax.set_title('{}'.format(ve), size=18) for ax, mode in zip(axes[:,0], ['Hillshade', 'hsv', 'overlay', 'soft']): ax.set_ylabel(mode, size=18) # Group labels... axes[0,1].annotate('Vertical Exaggeration', (0.5, 1), xytext=(0, 30), textcoords='offset points', xycoords='axes fraction', ha='center', va='bottom', size=20) axes[2,0].annotate('Blend Mode', (0, 0.5), xytext=(-30, 0), textcoords='offset points', xycoords='axes fraction', ha='right', va='center', size=20, rotation=90) fig.subplots_adjust(bottom=0.05, right=0.95) plt.show()

Open Graph Description: Currently, colors.LightSource preforms "hillshading" through methods that appear visually unrealistic in some cases (particularly topographic surfaces). This pull request: Refactors Li...

X Description: Currently, colors.LightSource preforms "hillshading" through methods that appear visually unrealistic in some cases (particularly topographic surfaces). This pull request: Refa...

Opengraph URL: https://github.com/matplotlib/matplotlib/pull/3291

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7e4d7ed0-bee4-77b9-4d97-32f5c6f0b1f6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDDF4:D7A7C:1D5E99D:26D9958:6B068EEA
html-safe-nonced14af1a8a9cd785b4e76cf95ce8b2579c7c14cba3df438fbb54f6831ae230888
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREY0OkQ3QTdDOjFENUU5OUQ6MjZEOTk1ODo2QjA2OEVFQSIsInZpc2l0b3JfaWQiOiIzMTIwMTMxNjI0NTA0MDM3MDk4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacde8c5b4c1354515ce33e750cf31dbb8e1ce3caad932b0af02128283cdd5c4e6f
hovercard-subject-tagpull_request:18755182
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/3291/files
twitter:imagehttps://avatars.githubusercontent.com/u/906803?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/906803?s=400&v=4
og:image:altCurrently, colors.LightSource preforms "hillshading" through methods that appear visually unrealistic in some cases (particularly topographic surfaces). This pull request: Refactors Li...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release6d3909414814ff86ce7da4c51a0f4918a13fb41b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/pull/3291/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fpull%2F3291%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fpull%2F3291%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/pull/3291/files
Reloadhttps://github.com/matplotlib/matplotlib/pull/3291/files
Reloadhttps://github.com/matplotlib/matplotlib/pull/3291/files
matplotlibhttps://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Codehttps://github.com/matplotlib/matplotlib
Issues1k (1k)https://github.com/matplotlib/matplotlib/issues
Pull requests429 (429)https://github.com/matplotlib/matplotlib/pulls
Actionshttps://github.com/matplotlib/matplotlib/actions
Projectshttps://github.com/matplotlib/matplotlib/projects
Wikihttps://github.com/matplotlib/matplotlib/wiki
Security and qualityhttps://github.com/matplotlib/matplotlib/security
Insightshttps://github.com/matplotlib/matplotlib/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fmatplotlib%2Fmatplotlib%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib%2Fissues%2Fnew%2Fchoose
jenshnielsenhttps://github.com/jenshnielsen
matplotlib:masterhttps://github.com/matplotlib/matplotlib/tree/master
joferkington:lightsource-enhancementshttps://github.com/joferkington/matplotlib/tree/lightsource-enhancements
Conversation 27 https://github.com/matplotlib/matplotlib/pull/3291
Commits 19 https://github.com/matplotlib/matplotlib/pull/3291/commits
Checks 0 https://github.com/matplotlib/matplotlib/pull/3291/checks
Files changed https://github.com/matplotlib/matplotlib/pull/3291/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/3291/files
Lightsource enhancements https://github.com/matplotlib/matplotlib/pull/3291/files#top
Show all changes 19 commits https://github.com/matplotlib/matplotlib/pull/3291/files
ee99cf5 Refactored LightSource.shade_rgb into three separate functions joferkington Jul 21, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/ee99cf589efc675cc524d70a15343f46b5293807
4faa454 Added support for vertical exag and non-uniform spacing to LightSource joferkington Jul 21, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/4faa4548c4cf2af3dc7d028379a3146169d7b139
a1af495 Added new blending modes to LightSource for more realistic rendering joferkington Jul 21, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/a1af495e106cda69c160e0d7b6ec02acd3d55537
ed5cd76 Updated shading example to show new styles and added exmaple DEM from… joferkington Jul 22, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/ed5cd76d231a8279633bde02e6549350c005fa82
0db6341 Make the "fraction" kwarg behave as it did before recent LightSource … joferkington Jul 23, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/0db6341ca220878f925df8b0fe230f81954766e9
52434ff Strip whitespace and strict PEP8 compliance joferkington Jul 23, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/52434ff91ab6ab31b09b14ee187a0fede11b049d
108eac7 Avoid potential divide by zero in LightSource.hillshade joferkington Jul 23, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/108eac73ecd256cb9728d54c2593cadac31cc650
f374383 Fix calculation of aspect for hillshading. joferkington Jul 25, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/f37438332cf34680892148ba616cc5a411cd8325
3c9cacf Make clipping work properly for effectively planar surfaces joferkington Jul 25, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/3c9cacf5c16f7e177382ab31ceb7386453235a0a
51e9a6c Added tests for LightSource functionality joferkington Jul 26, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/51e9a6cc51ded7f498115d8d7b2d8df53a9bafb4
31a4239 Added example of using the custom hillshading on a 3D surface plot joferkington Jul 26, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/31a42396742419842dc9dd2e7f8fb94fe3ed52b2
b3e2e3d PEP8 fixes joferkington Jul 26, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/b3e2e3d93c9e58a8e7f0fb0e0aa0f629e098b1b7
bdbc7df Avoid leaking file descriptors in tests and examples joferkington Jul 26, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/bdbc7df2579b6fabf606c720d9646177541c0cc9
71cb786 Added more examples joferkington Sep 26, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/71cb78653e490d01dee0cf41b69344087fb950ce
4afed00 Fixed hillshading problems with masked elevation arrays joferkington Sep 27, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/4afed00d7a90d07a958adf09c8b5ab81f7b52e67
abf8b87 Added array comparison tests for shaded relief joferkington Sep 27, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/abf8b87a6a49fbdae3a18b9de4d2d8bc70b180eb
ba1f492 Strict PEP8 compliance for printed arrays joferkington Sep 27, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/ba1f492e796e3baa48f8a51df19e6d8e2e3a7cde
ab40a2f Added *vmin* and *vmax* arguments to LightSource.shade joferkington Sep 27, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/ab40a2f2de9cfff9f48fdde7b62a29cdebc197b7
9fce26c Added LightSource changes summary to CHANGELOG joferkington Sep 27, 2014 https://github.com/matplotlib/matplotlib/pull/3291/commits/9fce26ce432c92d2fa0b0eeb14ec0e9dff3e29a1
Clear filters https://github.com/matplotlib/matplotlib/pull/3291/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/3291/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/3291/files
CHANGELOG https://github.com/matplotlib/matplotlib/pull/3291/files#diff-ecec88c33adb7591ee6aa88e29b62ad52ef443611cba5e0f0ecac9b5725afdba
custom_shaded_3d_surface.py https://github.com/matplotlib/matplotlib/pull/3291/files#diff-14bf1001198a3473fc627f7eb16d5c38493876aab9096ad24aeae61fd2c2281a
shading_example.py https://github.com/matplotlib/matplotlib/pull/3291/files#diff-c0068f2158c2a985541b4bfeaf19916d43d97bb227f60b777ce7ae9c2accece3
advanced_hillshading.py https://github.com/matplotlib/matplotlib/pull/3291/files#diff-2c5034229d8a3aef881491e275e71e592a79b1aff3922fe05b84bcac45245681
topographic_hillshading.py https://github.com/matplotlib/matplotlib/pull/3291/files#diff-950427da89ad1d6b3d5532aa27942fd69b9c1c95cc5b5c50e7e4e93e19c552a3
colors.py https://github.com/matplotlib/matplotlib/pull/3291/files#diff-3c08c967cdebbe0574ff68dceb5faba6cbb89ca53492e0fc3feeabc37cea37b6
jacksboro_fault_dem.npz https://github.com/matplotlib/matplotlib/pull/3291/files#diff-ddb1c9ad2ecbbf40247e51cb595ff0fc8a3c9fc6be2655a7c456ebfc09e6fe5d
light_source_shading_topo.png https://github.com/matplotlib/matplotlib/pull/3291/files#diff-d67f0cc25ae09c3806930e86d1f55b4bfcd56eebf816d24b6cfaaba5930c899f
test_colors.py https://github.com/matplotlib/matplotlib/pull/3291/files#diff-0b4e2edcbe7e1f81d3c7e56ac45d89a3aa1c8481d9204b2c0f497b3261006a87
CHANGELOGhttps://github.com/matplotlib/matplotlib/pull/3291/files#diff-ecec88c33adb7591ee6aa88e29b62ad52ef443611cba5e0f0ecac9b5725afdba
View file https://github.com/joferkington/matplotlib/blob/9fce26ce432c92d2fa0b0eeb14ec0e9dff3e29a1/CHANGELOG
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/3291/{{ revealButtonHref }}
https://github.com/matplotlib/matplotlib/pull/3291/files#diff-ecec88c33adb7591ee6aa88e29b62ad52ef443611cba5e0f0ecac9b5725afdba
examples/mplot3d/custom_shaded_3d_surface.pyhttps://github.com/matplotlib/matplotlib/pull/3291/files#diff-14bf1001198a3473fc627f7eb16d5c38493876aab9096ad24aeae61fd2c2281a
View file https://github.com/joferkington/matplotlib/blob/9fce26ce432c92d2fa0b0eeb14ec0e9dff3e29a1/examples/mplot3d/custom_shaded_3d_surface.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/3291/{{ revealButtonHref }}
examples/pylab_examples/shading_example.pyhttps://github.com/matplotlib/matplotlib/pull/3291/files#diff-c0068f2158c2a985541b4bfeaf19916d43d97bb227f60b777ce7ae9c2accece3
View file https://github.com/joferkington/matplotlib/blob/9fce26ce432c92d2fa0b0eeb14ec0e9dff3e29a1/examples/pylab_examples/shading_example.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/3291/{{ revealButtonHref }}
examples/specialty_plots/advanced_hillshading.pyhttps://github.com/matplotlib/matplotlib/pull/3291/files#diff-2c5034229d8a3aef881491e275e71e592a79b1aff3922fe05b84bcac45245681
View file https://github.com/joferkington/matplotlib/blob/9fce26ce432c92d2fa0b0eeb14ec0e9dff3e29a1/examples/specialty_plots/advanced_hillshading.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/3291/{{ revealButtonHref }}
examples/specialty_plots/topographic_hillshading.pyhttps://github.com/matplotlib/matplotlib/pull/3291/files#diff-950427da89ad1d6b3d5532aa27942fd69b9c1c95cc5b5c50e7e4e93e19c552a3
View file https://github.com/joferkington/matplotlib/blob/9fce26ce432c92d2fa0b0eeb14ec0e9dff3e29a1/examples/specialty_plots/topographic_hillshading.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/3291/{{ revealButtonHref }}
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/3291/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.