Title: [MNT]: ListedColormap inconsistencies · Issue #28763 · matplotlib/matplotlib · GitHub
Open Graph Title: [MNT]: ListedColormap inconsistencies · Issue #28763 · matplotlib/matplotlib
X Title: [MNT]: ListedColormap inconsistencies · Issue #28763 · matplotlib/matplotlib
Description: Summary The documentation to ListedColormap states that the input should be a list or array matplotlib/lib/matplotlib/colors.py Lines 1175 to 1177 in b01462c colors : list, array Sequence of Matplotlib color specifications (color names o...
Open Graph Description: Summary The documentation to ListedColormap states that the input should be a list or array matplotlib/lib/matplotlib/colors.py Lines 1175 to 1177 in b01462c colors : list, array Sequence of Matplo...
X Description: Summary The documentation to ListedColormap states that the input should be a list or array matplotlib/lib/matplotlib/colors.py Lines 1175 to 1177 in b01462c colors : list, array Sequence of Matplo...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28763
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[MNT]: ListedColormap inconsistencies","articleBody":"### Summary\r\n\r\nThe documentation to `ListedColormap` states that the input should be a list or array\r\nhttps://github.com/matplotlib/matplotlib/blob/b01462c9ac7b0d3875892d6f40c9213c56f0864f/lib/matplotlib/colors.py#L1175-L1177\r\n\r\nHowever, when specifying *N*, `str` and `float` are also supported (if one use the source code)\r\nhttps://github.com/matplotlib/matplotlib/blob/b01462c9ac7b0d3875892d6f40c9213c56f0864f/lib/matplotlib/colors.py#L1199-L1214\r\n\r\nThis means that, e.g., `ListedColormap(\"#aabbcc\", N=1)` works, but `ListedColormap(\"#aabbcc\")` does not (there will be weird errors later, like `N=7` for the latter). Given that there is `monochrome` attribute and the documentation of *N*, one may expect the latter to work as well (if the earlier works). Also, `ListedColormap([\"#aabbcc\"])` will not set the `monochrome` attribute correctly.\r\n\r\n### Proposed fix\r\n\r\nI think there are three(?) possible solutions:\r\n* Support scalars/strings when *N* is not provided (and ideally documents that)\r\n* Document that if *N* is not None, the first argument can be a scalar or string (it is maybe easier to do `ListedColormap(0.3, N=7)` than `ListedColormap([0.3]*7)` or at least require slightly less Python knowledge)\r\n* Deprecate scalar/string argument\r\n\r\nBonus: document the `color` and `monochrome` attributes","author":{"url":"https://github.com/oscargus","@type":"Person","name":"oscargus"},"datePublished":"2024-08-29T09:04:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/28763/matplotlib/issues/28763"}
| 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:8960534f-0af6-343b-bef8-2bafcfb0691d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE32:B0958:28F1DF3:363EC8A:6A521631 |
| html-safe-nonce | 71e84dde0de5e266a4c7dec44d2ff6001b2f549310ddad810b20557638968995 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTMyOkIwOTU4OjI4RjFERjM6MzYzRUM4QTo2QTUyMTYzMSIsInZpc2l0b3JfaWQiOiIxNzEwMzEyNzk3MTczMzIzMzE0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 006fa854ac5abcf7e2ec0536930f60683c37aa84b71ace36cab34117346aa837 |
| hovercard-subject-tag | issue:2493866240 |
| 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/28763/issue_layout |
| twitter:image | https://opengraph.githubassets.com/08cbd193e95642d344151760a59d10b3f4d74fb3b88a61c015e89eea30308a96/matplotlib/matplotlib/issues/28763 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/08cbd193e95642d344151760a59d10b3f4d74fb3b88a61c015e89eea30308a96/matplotlib/matplotlib/issues/28763 |
| og:image:alt | Summary The documentation to ListedColormap states that the input should be a list or array matplotlib/lib/matplotlib/colors.py Lines 1175 to 1177 in b01462c colors : list, array Sequence of Matplo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | oscargus |
| 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