Title: [Bug]: pcolormesh passes alpha value down to colormap instead of alpha blending · Issue #29761 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: pcolormesh passes alpha value down to colormap instead of alpha blending · Issue #29761 · matplotlib/matplotlib
X Title: [Bug]: pcolormesh passes alpha value down to colormap instead of alpha blending · Issue #29761 · matplotlib/matplotlib
Description: Bug summary Using a combination of the following: pcolormesh with a set alpha parameter a colormap that uses the alpha channel for color mapping results in the colormap using the alpha parameter from pcolormesh as a constant. Expected re...
Open Graph Description: Bug summary Using a combination of the following: pcolormesh with a set alpha parameter a colormap that uses the alpha channel for color mapping results in the colormap using the alpha parameter fr...
X Description: Bug summary Using a combination of the following: pcolormesh with a set alpha parameter a colormap that uses the alpha channel for color mapping results in the colormap using the alpha parameter fr...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29761
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: pcolormesh passes alpha value down to colormap instead of alpha blending","articleBody":"### Bug summary\n\nUsing a combination of the following:\n* pcolormesh with a set alpha parameter\n* a colormap that uses the alpha channel for color mapping\nresults in the colormap using the alpha parameter from pcolormesh as a constant.\n\nExpected result would be that all resulting values from the colormapping are additionally blended with the alpha parameter from pcolormesh.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nimport matplotlib.colors\n\ncdict ={'red':[(0.0, None, 1.0),\n (1.0, 1.0, None)],\n 'green': [(0.0, None, 0.0),\n (1.0, 0.0, None)],\n 'blue': [(0.0, None, 0.0),\n (1.0, 0.0, None)],\n 'alpha': [(0.0, None, 0.0),\n (1.0, 1.0, None)]}\ncmap = matplotlib.colors.LinearSegmentedColormap('custom',cdict,256)\n\nH = [[1,2,3]]\nyedges = [0,1]\nxedges = [0,1,2,3]\n\nf, (ax1, ax2) = plt.subplots(2, 1)\n\n# case 1: no alpha, colormap defines alpha of values\nax1.pcolormesh(xedges, yedges, H, cmap=cmap)\nax1.set_title(\"pcolormesh without alpha parameter\")\n\n# case 2: with alpha, alpha is passed to colormap and every value has the same alpha\nax2.pcolormesh(xedges, yedges, H, cmap=cmap, alpha=0.5)\nax2.set_title(\"pcolormesh with alpha parameter 0.5\")\n\nplt.show()\n```\n\n### Actual outcome\n\n\u003cimg width=\"573\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/68477255-30d7-4a4b-9b21-4eee0d29b4d0\" /\u003e\n\n### Expected outcome\n\n\u003cimg width=\"559\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/cabe6f6d-01e8-4e39-9570-daa1c8b0a1ce\" /\u003e\n\nThe expected outcome is, that the \"normal\" output of pcolormesh is *additionally* alpha blended.\n\n### Additional information\n\nThis happens when an alpha parameter is passed to pcolormesh.\nI suspect that the alpha parameter is passed to the colormap call, which effectively sets the colormap result alpha value to a constant.\n\n### Operating system\n\nMacOS\n\n### Matplotlib Version\n\n3.10.1\n\n### Matplotlib Backend\n\nmacosx\n\n### Python version\n\nPython 3.13.1\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/aw32","@type":"Person","name":"aw32"},"datePublished":"2025-03-16T14:21:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/29761/matplotlib/issues/29761"}
| 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:d215a586-7050-a97e-34b0-66debddd1306 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6A4:29DE49:7F8536:A98FB4:6A5272BB |
| html-safe-nonce | f24935f828c1ba83b1e89d8ae28462d2a8f189d6969fde583d4c9c5e1e3d50ce |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkE0OjI5REU0OTo3Rjg1MzY6QTk4RkI0OjZBNTI3MkJCIiwidmlzaXRvcl9pZCI6IjEyNDU0NzU2ODkzODc0MjIzOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e0104d59d102024f746d20afed3e3d071069a73ceedbeb6995a24ab7c8f44b10 |
| hovercard-subject-tag | issue:2923095421 |
| 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/29761/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a930cdc2b68ae141ce7780ef20ba8857d3339f853b239dbaf595d458fb01551b/matplotlib/matplotlib/issues/29761 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a930cdc2b68ae141ce7780ef20ba8857d3339f853b239dbaf595d458fb01551b/matplotlib/matplotlib/issues/29761 |
| og:image:alt | Bug summary Using a combination of the following: pcolormesh with a set alpha parameter a colormap that uses the alpha channel for color mapping results in the colormap using the alpha parameter fr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aw32 |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width