Title: [Bug]: Regression in 3.11.0 with LinearSegmentedColormap · Issue #31939 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Regression in 3.11.0 with LinearSegmentedColormap · Issue #31939 · matplotlib/matplotlib
X Title: [Bug]: Regression in 3.11.0 with LinearSegmentedColormap · Issue #31939 · matplotlib/matplotlib
Description: Bug summary Minimal test case using LinearSegmentedColormap extracted from https://github.com/pyani-plus/pyani-plus/blob/v1.0.1/pyani_plus/plot_run.py which worked on macOS and Linux with eg matplotlib==3.10.8 but breaks on matplotlib-3....
Open Graph Description: Bug summary Minimal test case using LinearSegmentedColormap extracted from https://github.com/pyani-plus/pyani-plus/blob/v1.0.1/pyani_plus/plot_run.py which worked on macOS and Linux with eg matplo...
X Description: Bug summary Minimal test case using LinearSegmentedColormap extracted from https://github.com/pyani-plus/pyani-plus/blob/v1.0.1/pyani_plus/plot_run.py which worked on macOS and Linux with eg matplo...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31939
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Regression in 3.11.0 with LinearSegmentedColormap","articleBody":"### Bug summary\n\nMinimal test case using `LinearSegmentedColormap` extracted from https://github.com/pyani-plus/pyani-plus/blob/v1.0.1/pyani_plus/plot_run.py which worked on macOS and Linux with eg `matplotlib==3.10.8` but breaks on `matplotlib-3.11.0` with:\n\n`ValueError: the values passed in the (value, color) pairs must increase monotonically from 0 to 1.`\n\nThe release notes API changes do not mention this, https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.11.0.html\n\n### Code for reproduction\n\n```Python\nfrom matplotlib import colormaps, __version__\nfrom matplotlib.colors import LinearSegmentedColormap\n\nprint(f\"matplotlib {__version__}\")\n\nGREY = (0.7, 0.7, 0.7)\nDULL_BLUE = (0.137, 0.412, 0.737)\nWHITE = (1.0, 1.0, 1.0)\nDULL_RED = (0.659, 0.216, 0.231)\n\ncolormaps.register(\n LinearSegmentedColormap.from_list(\n \"spbnd_BuRd\", # species boundary - blue to red\n (\n (0.00, GREY), # 0% grey\n (0.80, GREY), # 80% grey (not meaningful)\n (0.80, DULL_BLUE), # 80% blue\n (0.95, WHITE), # 95% white (species boundary)\n (1.00, DULL_RED), # 100% red\n ),\n )\n)\n\nprint(\"Done\")\n```\n\n### Actual outcome\n\nIt now fails:\n\n```\n❯ pip install matplotlib==3.11.0\nCollecting matplotlib==3.11.0\n...\nSuccessfully installed matplotlib-3.11.0\n\n❯ python test.py\nmatplotlib 3.11.0\nTraceback (most recent call last):\n File \"/Users/peterjc/miniforge3/envs/pyani-plus_py312/lib/python3.12/site-packages/matplotlib/colors.py\", line 1218, in from_list\n r, g, b, a = to_rgba_array(colors).T\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/peterjc/miniforge3/envs/pyani-plus_py312/lib/python3.12/site-packages/matplotlib/colors.py\", line 532, in to_rgba_array\n rgba = np.array([to_rgba(cc) for cc in c])\n ^^^^^^^^^^^\n File \"/Users/peterjc/miniforge3/envs/pyani-plus_py312/lib/python3.12/site-packages/matplotlib/colors.py\", line 345, in to_rgba\n rgba = _to_rgba_no_colorcycle(c, alpha)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/peterjc/miniforge3/envs/pyani-plus_py312/lib/python3.12/site-packages/matplotlib/colors.py\", line 364, in _to_rgba_no_colorcycle\n if alpha is not None and not 0 \u003c= alpha \u003c= 1:\n ^^^^^^^^^^^^^^^\nTypeError: '\u003c=' not supported between instances of 'int' and 'tuple'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/private/tmp/test.py\", line 12, in \u003cmodule\u003e\n LinearSegmentedColormap.from_list(\n File \"/Users/peterjc/miniforge3/envs/pyani-plus_py312/lib/python3.12/site-packages/matplotlib/colors.py\", line 1229, in from_list\n raise ValueError(\nValueError: the values passed in the (value, color) pairs must increase monotonically from 0 to 1.\n```\n\n### Expected outcome\n\nThis used to work, eg\n\n```\n❯ pip install matplotlib==3.10.8\nCollecting matplotlib==3.10.8\n...\nSuccessfully installed matplotlib-3.10.8\n\n❯ python test.py\nmatplotlib 3.10.8\nDone\n```\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.11.0\n\n### Matplotlib Backend\n\nmacosx (or Linux tested via CI)\n\n### Python version\n\n3.12.10 (and Python 3.11 and 3.13 via CI)\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/peterjc","@type":"Person","name":"peterjc"},"datePublished":"2026-06-23T09:50:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/31939/matplotlib/issues/31939"}
| 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:f2381d93-9ebd-747a-f689-6585a38276d9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD5E:2D3512:E1B8C2:12C8D62:6A52918A |
| html-safe-nonce | 7d4a07f65a53e81b483cd52ad45beac20baddf08200af88a82f1171e2b686cd5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDVFOjJEMzUxMjpFMUI4QzI6MTJDOEQ2Mjo2QTUyOTE4QSIsInZpc2l0b3JfaWQiOiI3MzQ5MDA5MjAwNjkxOTc0NTM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 53e87c18de47556a810136121bf8d26f1450c8223a777bebcfc4066b78d3a378 |
| hovercard-subject-tag | issue:4724642760 |
| 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/31939/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1821dac0bdb92290a2d527ea3e01f15d4fe042395721fd0a1b438feb80180651/matplotlib/matplotlib/issues/31939 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1821dac0bdb92290a2d527ea3e01f15d4fe042395721fd0a1b438feb80180651/matplotlib/matplotlib/issues/31939 |
| og:image:alt | Bug summary Minimal test case using LinearSegmentedColormap extracted from https://github.com/pyani-plus/pyani-plus/blob/v1.0.1/pyani_plus/plot_run.py which worked on macOS and Linux with eg matplo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | peterjc |
| 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