Title: [Bug]: colors.LinearSegmentedColormap.from_list does not take two tuples in 3.8.0 · Issue #26949 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: colors.LinearSegmentedColormap.from_list does not take two tuples in 3.8.0 · Issue #26949 · matplotlib/matplotlib
X Title: [Bug]: colors.LinearSegmentedColormap.from_list does not take two tuples in 3.8.0 · Issue #26949 · matplotlib/matplotlib
Description: Bug summary Incrementing from v3.7 to v3.8 the option to specify a start and end value is no longer functioning when two values are specified. It still works when three are specified. ## This works: matplotlib.colors.LinearSegmentedColor...
Open Graph Description: Bug summary Incrementing from v3.7 to v3.8 the option to specify a start and end value is no longer functioning when two values are specified. It still works when three are specified. ## This works...
X Description: Bug summary Incrementing from v3.7 to v3.8 the option to specify a start and end value is no longer functioning when two values are specified. It still works when three are specified. ## This works...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/26949
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: colors.LinearSegmentedColormap.from_list does not take two tuples in 3.8.0","articleBody":"### Bug summary\r\n\r\nIncrementing from v3.7 to v3.8 the option to specify a start and end value is no longer functioning when two values are specified. It still works when three are specified.\r\n\r\n``` \r\n## This works:\r\nmatplotlib.colors.LinearSegmentedColormap.from_list(\"myMap\", [\"#000000\", \"#FFFFFF\"])\r\n```\r\n\r\n``` \r\n## This does not:\r\nmatplotlib.colors.LinearSegmentedColormap.from_list(\"myMap\", [(0,\"#000000\"), (1,\"#FFFFFF\")])\r\n```\r\n\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nmatplotlib.colors.LinearSegmentedColormap.from_list(\"myMap\", [(0,\"#000000\"), (1,\"#FFFFFF\")])\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/Users/dave/.local/share/virtualenvs/projects-t0xU6-ce/lib/python3.10/site-packages/matplotlib/colors.py\", line 1065, in from_list\r\n colors : array-like of colors or array-like of (value, color)\r\n File \"/Users/dave/.local/share/virtualenvs/projects-t0xU6-ce/lib/python3.10/site-packages/matplotlib/colors.py\", line 489, in to_rgba_array\r\n pass\r\nValueError: '#000000' is not a valid color value.\r\n\r\n### Expected outcome\r\n\r\n\u003cmatplotlib.colors.LinearSegmentedColormap object at 0x101e7f520\u003e\r\n\r\n### Additional information\r\n\r\nWorked in 3.7\r\n\r\nThe issue I think is related to zipped values being passed to `r, g, b, a = to_rgba_array(colors).T`. A tuple gets passed in rather than a list.\r\n\r\n```\r\n## tuple len 2 fails\r\n\u003e\u003e\u003e matplotlib.colors.to_rgba_array((\"#000000\", \"#FFFFFF\"))\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/Users/dave/.local/share/virtualenvs/model_train-t0xU6-ce/lib/python3.10/site-packages/matplotlib/colors.py\", line 489, in to_rgba_array\r\n pass\r\nValueError: '#000000' is not a valid color value.\r\n## list works\r\n\u003e\u003e\u003e matplotlib.colors.to_rgba_array([\"#000000\", \"#FFFFFF\"])\r\narray([[0., 0., 0., 1.],\r\n [1., 1., 1., 1.]])\r\n```\r\n\r\nChanging `r, g, b, a = to_rgba_array(colors).T` in `colors.py:LinearSegmentedColormap.from_list` to `r, g, b, a = to_rgba_array(list(colors)).T` or similar may fix.\r\n\r\n\r\n### Operating system\r\n\r\nOS/X\r\n\r\n### Matplotlib Version\r\n\r\n3.8.0\r\n\r\n### Matplotlib Backend\r\n\r\nMacOSX\r\n\r\n### Python version\r\n\r\nPython 3.10.9\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\nNone","author":{"url":"https://github.com/dave-shirley-faraday","@type":"Person","name":"dave-shirley-faraday"},"datePublished":"2023-09-28T16:59:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/26949/matplotlib/issues/26949"}
| 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:847c5f0b-bb6b-5b5a-5dbe-f20a034fd039 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CBF4:BE64B:3B29FE:501827:6A514349 |
| html-safe-nonce | 30a032a8b5d1b6cf076df0a292faa6cdbf980dd35af8054fbbd9df6944822216 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkY0OkJFNjRCOjNCMjlGRTo1MDE4Mjc6NkE1MTQzNDkiLCJ2aXNpdG9yX2lkIjoiNDM2MDA3NzEzNzk3NTI2NDA3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 93d1ab55f8dec39e61f84c3af54e5842799deee939824d2002000b3b72a85e90 |
| hovercard-subject-tag | issue:1917938164 |
| 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/26949/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c46b5b18cc6ad009bbee41448a366e27f27c3bc8ebb09939933f604c1ec9361a/matplotlib/matplotlib/issues/26949 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c46b5b18cc6ad009bbee41448a366e27f27c3bc8ebb09939933f604c1ec9361a/matplotlib/matplotlib/issues/26949 |
| og:image:alt | Bug summary Incrementing from v3.7 to v3.8 the option to specify a start and end value is no longer functioning when two values are specified. It still works when three are specified. ## This works... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dave-shirley-faraday |
| hostname | github.com |
| expected-hostname | github.com |
| None | e840f405b2718e8f2d55aafa9ff27dbce17e29d0c253011d05ea0fea3c78baff |
| 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 | b78565f6aa43cc5323c9935ec11b22cca7bb0a62 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width