René's URL Explorer Experiment


Title: ENH: Extend gouraud shading to support data at quadrilateral centers by lucaznch · Pull Request #31362 · matplotlib/matplotlib · GitHub

Open Graph Title: ENH: Extend gouraud shading to support data at quadrilateral centers by lucaznch · Pull Request #31362 · matplotlib/matplotlib

X Title: ENH: Extend gouraud shading to support data at quadrilateral centers by lucaznch · Pull Request #31362 · matplotlib/matplotlib

Description: PR summary This PR extends the gouraud shading in Axes.pcolormesh to support data defined at the centers of quadrilaterals, where X and Y are one larger than Z in each dimension. In this situation, gouraud automatically converts the grid internally to match the data's shape by replacing each quadrilateral with a point at its center, computed as the average of its four corners, and then applies Gouraud shading. Why is this change necessary / what problem does it solve? pcolormesh with shading='gouraud' requires the data to be defined at the corners of quadrilaterals, meaning X, Y and Z must have the same shape. If the user is working with data defined at the centers, so that X and Y are one larger in each dimension, and tries to use shading='gouraud' for a smooth color interpolation, a TypeError is raised. This now allows pcolormesh to provide both constant and linearly interpolated shading for each data/grid configuration. Shading can be switched for the same data location, allowing switches between nearest and gouraud, and now also between flat and gouraud. constant linearly interpolated data at grid quad corners (X, Y, Z same shape) nearest gouraud data at grid quad centers (X, Y one larger than Z) flat gouraud What is the reasoning for this implementation? Following discussion on the issue and in this PR, the approach taken is to extend the existing gouraud shading. Edit: The initial version of this PR introduced a new shading, called centered-gouraud, in pcolormesh. This shading was a variant of gouraud dedicated to handle the case of data defined at quadrilateral centers (with X and Y one larger than Z), by performing the same grid conversion described above. Following discussion in this PR, the approach was revised to extend the existing gouraud shading instead. Example nrows, ncols = 3, 5 Z = np.arange(nrows * ncols).reshape(nrows, ncols) x = np.arange(ncols + 1) y = np.arange(nrows + 1) _, axs = plt.subplots(2, 2, layout='constrained') # Data at corners, requires X and Y the same shape as Z. axs[0, 0].pcolormesh(x[:-1], y[:-1], Z, shading='nearest') axs[0, 1].pcolormesh(x[:-1], y[:-1], Z, shading='gouraud') # Data at centers, requires X and Y one larger than Z. axs[1, 0].pcolormesh(x, y, Z, shading='flat') axs[1, 1].pcolormesh(x, y, Z, shading='gouraud') # works now Closes #8422 AI Disclosure I used AI tools to help proofread and improve the grammar of this PR description. The code logic and implementation are my own. PR checklist "closes #0000" is in the body of the PR description to link the related issue new and changed code is tested Plotting related features are demonstrated in an example New Features and API Changes are noted with a directive and release note Documentation complies with general and docstring guidelines

Open Graph Description: PR summary This PR extends the gouraud shading in Axes.pcolormesh to support data defined at the centers of quadrilaterals, where X and Y are one larger than Z in each dimension. In this situation,...

X Description: PR summary This PR extends the gouraud shading in Axes.pcolormesh to support data defined at the centers of quadrilaterals, where X and Y are one larger than Z in each dimension. In this situation,...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7e158ee8-b3f9-083c-1905-b2d8875bbe72
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD0EE:B2127:1F8193:2ABCBF:6A526A82
html-safe-nonced87625fc88c2ecbc2bfa5b16f75928e63120cc554e8b7936bb29508683f6ce6a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEVFOkIyMTI3OjFGODE5MzoyQUJDQkY6NkE1MjZBODIiLCJ2aXNpdG9yX2lkIjoiNzI1MjI0MTc4MzYyNjgyMDIyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace4a73fcb318894bcc8c8a99ca6ae49bf1e059048d2d842593b5704e91cd37e5a
hovercard-subject-tagpull_request:3437953771
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/31362/files
twitter:imagehttps://avatars.githubusercontent.com/u/104226137?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/104226137?s=400&v=4
og:image:altPR summary This PR extends the gouraud shading in Axes.pcolormesh to support data defined at the centers of quadrilaterals, where X and Y are one larger than Z in each dimension. In this situation,...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
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
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/pull/31362/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fpull%2F31362%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fpull%2F31362%2Ffiles
Sign up https://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/31362/files
Reloadhttps://github.com/matplotlib/matplotlib/pull/31362/files
Reloadhttps://github.com/matplotlib/matplotlib/pull/31362/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/31362/files
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/31362/files
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 408 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
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
lucaznchhttps://github.com/lucaznch
matplotlib:mainhttps://github.com/matplotlib/matplotlib/tree/main
lucaznch:centered-gouraudhttps://github.com/lucaznch/matplotlib/tree/centered-gouraud
Conversation 49 https://github.com/matplotlib/matplotlib/pull/31362
Commits 3 https://github.com/matplotlib/matplotlib/pull/31362/commits
Checks 38 https://github.com/matplotlib/matplotlib/pull/31362/checks
Files changed 4 https://github.com/matplotlib/matplotlib/pull/31362/files
ENH: Extend gouraud shading to support data at quadrilateral centers https://github.com/matplotlib/matplotlib/pull/31362/files#top
Show all changes 3 commits https://github.com/matplotlib/matplotlib/pull/31362/files
bf03b20 ENH: Extend gouraud shading to support data at quad centers lucaznch Apr 1, 2026 https://github.com/matplotlib/matplotlib/pull/31362/commits/bf03b202ada7d1109b79441dfa823b3204fe0f24
6fbb514 DOC: Clarify gouraud shading lucaznch Apr 28, 2026 https://github.com/matplotlib/matplotlib/pull/31362/commits/6fbb514191f84759eb7238421185b5cc0f3337af
7b5b0d6 DOC: Improve documentation lucaznch Jun 30, 2026 https://github.com/matplotlib/matplotlib/pull/31362/commits/7b5b0d622819b2997310255e933b0e5ce5199fdf
Clear filters https://github.com/matplotlib/matplotlib/pull/31362/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/31362/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/31362/files
pcolormesh_gouraud.rst https://github.com/matplotlib/matplotlib/pull/31362/files#diff-aa8e63c6d40f54d6649dc76c792e22c873169347e0d58052316a9382cd7dab57
pcolormesh_grids.py https://github.com/matplotlib/matplotlib/pull/31362/files#diff-0b78acc2f4eeb568cb5a6e0e8a0439fbb14760b9557422add3b28acd9ef7bf13
_axes.py https://github.com/matplotlib/matplotlib/pull/31362/files#diff-608e2a1bf3d32fd631b0763599a3334d59822c11cb4fec1fa7398c9714592900
test_axes.py https://github.com/matplotlib/matplotlib/pull/31362/files#diff-ef5144bd27a700deb760ef56ccf51dc6fcfe86723f9ffa84df7f024985bf3ee7
doc/release/next_whats_new/pcolormesh_gouraud.rsthttps://github.com/matplotlib/matplotlib/pull/31362/files#diff-aa8e63c6d40f54d6649dc76c792e22c873169347e0d58052316a9382cd7dab57
View file https://github.com/matplotlib/matplotlib/blob/7b5b0d622819b2997310255e933b0e5ce5199fdf/doc/release/next_whats_new/pcolormesh_gouraud.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/31362/{{ revealButtonHref }}
galleries/examples/images_contours_and_fields/pcolormesh_grids.pyhttps://github.com/matplotlib/matplotlib/pull/31362/files#diff-0b78acc2f4eeb568cb5a6e0e8a0439fbb14760b9557422add3b28acd9ef7bf13
View file https://github.com/matplotlib/matplotlib/blob/7b5b0d622819b2997310255e933b0e5ce5199fdf/galleries/examples/images_contours_and_fields/pcolormesh_grids.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/31362/{{ revealButtonHref }}
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-0b78acc2f4eeb568cb5a6e0e8a0439fbb14760b9557422add3b28acd9ef7bf13
jklymakhttps://github.com/jklymak
Jun 30, 2026https://github.com/matplotlib/matplotlib/pull/31362/files#r3500996171
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/31362/files
lucaznchhttps://github.com/lucaznch
Jun 30, 2026https://github.com/matplotlib/matplotlib/pull/31362/files#r3502237010
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/31362/files
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-0b78acc2f4eeb568cb5a6e0e8a0439fbb14760b9557422add3b28acd9ef7bf13
lib/matplotlib/axes/_axes.pyhttps://github.com/matplotlib/matplotlib/pull/31362/files#diff-608e2a1bf3d32fd631b0763599a3334d59822c11cb4fec1fa7398c9714592900
View file https://github.com/matplotlib/matplotlib/blob/7b5b0d622819b2997310255e933b0e5ce5199fdf/lib/matplotlib/axes/_axes.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/31362/{{ revealButtonHref }}
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-608e2a1bf3d32fd631b0763599a3334d59822c11cb4fec1fa7398c9714592900
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-608e2a1bf3d32fd631b0763599a3334d59822c11cb4fec1fa7398c9714592900
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-608e2a1bf3d32fd631b0763599a3334d59822c11cb4fec1fa7398c9714592900
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-608e2a1bf3d32fd631b0763599a3334d59822c11cb4fec1fa7398c9714592900
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-608e2a1bf3d32fd631b0763599a3334d59822c11cb4fec1fa7398c9714592900
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-608e2a1bf3d32fd631b0763599a3334d59822c11cb4fec1fa7398c9714592900
lib/matplotlib/tests/test_axes.pyhttps://github.com/matplotlib/matplotlib/pull/31362/files#diff-ef5144bd27a700deb760ef56ccf51dc6fcfe86723f9ffa84df7f024985bf3ee7
View file https://github.com/matplotlib/matplotlib/blob/7b5b0d622819b2997310255e933b0e5ce5199fdf/lib/matplotlib/tests/test_axes.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/matplotlib/matplotlib/pull/31362/{{ revealButtonHref }}
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-ef5144bd27a700deb760ef56ccf51dc6fcfe86723f9ffa84df7f024985bf3ee7
jklymakhttps://github.com/jklymak
Jun 30, 2026https://github.com/matplotlib/matplotlib/pull/31362/files#r3501015891
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/31362/files
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-ef5144bd27a700deb760ef56ccf51dc6fcfe86723f9ffa84df7f024985bf3ee7
https://github.com/matplotlib/matplotlib/pull/31362/files#diff-ef5144bd27a700deb760ef56ccf51dc6fcfe86723f9ffa84df7f024985bf3ee7
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/31362/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

Viewport: width=device-width


URLs of crawlers that visited me.