Title: [ENH]: Mixed shading in pcolor/pcolormesh · Issue #31607 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: Mixed shading in pcolor/pcolormesh · Issue #31607 · matplotlib/matplotlib
X Title: [ENH]: Mixed shading in pcolor/pcolormesh · Issue #31607 · matplotlib/matplotlib
Description: Problem Currently pcolor/pcolormesh support x and y coordinate grids that have either the same size as the 2D array to plot (shading='nearest'), or one larger than the array (shading='flat'). However, it is not possible to plot an array ...
Open Graph Description: Problem Currently pcolor/pcolormesh support x and y coordinate grids that have either the same size as the 2D array to plot (shading='nearest'), or one larger than the array (shading='flat'). Howev...
X Description: Problem Currently pcolor/pcolormesh support x and y coordinate grids that have either the same size as the 2D array to plot (shading='nearest'), or one larger than the array (shading='f...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31607
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: Mixed shading in pcolor/pcolormesh","articleBody":"### Problem\n\nCurrently [pcolor](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolor.html)/[pcolormesh](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolormesh.html) support `x` and `y` coordinate grids that have either the same size as the 2D array to plot (`shading='nearest'`), or one larger than the array (`shading='flat'`). However, it is not possible to plot an array with a coordinate grid with the same size along one dimension and one larger along the other, i.e using one shading method along `x` and the other along `y`.\n\nAn example of data in this shape I occasionally deal with are spectra defined by the edges of the frequency bins, given at a number of points in time which I would like to plot as a spectrogram. Currently, it is not possible to make such a plot without adjusting the coordinate grid before the call to pcolor/pcolormesh .\n\n\n### Proposed solution\n\nI would propose to allow specifying the shading style individually for both dimensions and to determine the shading style individually for both dimensions as well when using `shading='auto'`. To do so, the [grid interpolation](https://github.com/matplotlib/matplotlib/blob/dd8d78b8dce60b6c8db86132892577a0b9dbe469/lib/matplotlib/axes/_axes.py#L5998) would have to be adjusted to do the grid interpolation along both dimensions separately.\n\nTo illustrate the proposed feature, an extended [pcolormesh grids and shading example](https://matplotlib.org/stable/gallery/images_contours_and_fields/pcolormesh_grids.html#auto-shading) would look like this:\n\n\u003cimg width=\"640\" height=\"960\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/020c0390-f835-4f55-b477-6d7c19bb612f\" /\u003e","author":{"url":"https://github.com/Bzero","@type":"Person","name":"Bzero"},"datePublished":"2026-05-02T13:26:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/31607/matplotlib/issues/31607"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:70a4b786-c31f-bc41-84f4-4043b5167abe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CBCE:14F3B3:D2CCDA:11F3095:6A521423 |
| html-safe-nonce | 10c5acd650dfe2eb93b9d6ad876af14c705da8655e43dbb7a24e974327982fe4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkNFOjE0RjNCMzpEMkNDREE6MTFGMzA5NTo2QTUyMTQyMyIsInZpc2l0b3JfaWQiOiIzODUyODc1OTA3MzAwNzI1Nzk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 071955465388a7bf2e9b9f7736a9b577b3fe20f0115d6e71f14805954b039f79 |
| hovercard-subject-tag | issue:4369008584 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/31607/issue_layout |
| twitter:image | https://opengraph.githubassets.com/915c5fa7d8f81ce7a7c7e4586dc5d65f25bc429f76f3e03ada8a628ec6d2a263/matplotlib/matplotlib/issues/31607 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/915c5fa7d8f81ce7a7c7e4586dc5d65f25bc429f76f3e03ada8a628ec6d2a263/matplotlib/matplotlib/issues/31607 |
| og:image:alt | Problem Currently pcolor/pcolormesh support x and y coordinate grids that have either the same size as the 2D array to plot (shading='nearest'), or one larger than the array (shading='flat'). Howev... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Bzero |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width