Title: [ENH]: BoundaryNorm should not need to know colormap length · Issue #21911 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: BoundaryNorm should not need to know colormap length · Issue #21911 · matplotlib/matplotlib
X Title: [ENH]: BoundaryNorm should not need to know colormap length · Issue #21911 · matplotlib/matplotlib
Description: Problem Currently BoundaryNorm requires ncolors as an argument, and hence the user needs to know the colormap size to use it. Then we have this comment in the code # Mapping to the 0-1 interval could have been done via piece-wise linear ...
Open Graph Description: Problem Currently BoundaryNorm requires ncolors as an argument, and hence the user needs to know the colormap size to use it. Then we have this comment in the code # Mapping to the 0-1 interval cou...
X Description: Problem Currently BoundaryNorm requires ncolors as an argument, and hence the user needs to know the colormap size to use it. Then we have this comment in the code # Mapping to the 0-1 interval cou...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21911
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: BoundaryNorm should not need to know colormap length","articleBody":"### Problem\n\nCurrently `BoundaryNorm` requires `ncolors` as an argument, and hence the user needs to know the colormap size to use it. \r\n\r\nThen we have this comment in the code\r\n```python\r\n # Mapping to the 0-1 interval could have been done via piece-wise linear\r\n # interpolation, but using integers seems simpler, and reduces the number\r\n # of conversions back and forth between int and float.\r\n```\r\n\r\nand this \"note\" in the docstring:\r\n\r\n```python\r\n\"\"\"\r\n If there are fewer bins (including extensions) than colors, then the\r\n color index is chosen by linearly interpolating the ``[0, nbins - 1]``\r\n range onto the ``[0, ncolors - 1]`` range, effectively skipping some\r\n colors in the middle of the colormap.\r\n\"\"\"\r\n```\r\n\r\nIf we are going to interpolate anyway, we should just map from 0-1 with `len(boundaries)` boundaries like all the other norms. Then the user doesn't need to specify Ncolors. In fact, if the user mispecifies the length of the colormap, then the mapping will mysteriously be incorrect. (Yes there is a fast-path of len(boundaries)-1 == ncolors, but I really don't think `np.digitize` is one of our performance chokepoints)\n\n### Proposed solution\n\nThe problem with changing this is tracking down the special cases, and possible with downstream libraries that do something with the Norm. The other problem is somehow deprecating the argument. ","author":{"url":"https://github.com/jklymak","@type":"Person","name":"jklymak"},"datePublished":"2021-12-10T09:59:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/21911/matplotlib/issues/21911"}
| 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:bada111b-4e2e-c44b-8b7a-d453049f0a02 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 999A:134698:5F11DC:80D443:6A51EC44 |
| html-safe-nonce | 5656341b506093f053be6ad8f9f29db9981163ad5834f16e5c7643960bd0c927 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTlBOjEzNDY5ODo1RjExREM6ODBENDQzOjZBNTFFQzQ0IiwidmlzaXRvcl9pZCI6IjI3OTQzODAyODA4OTg2NDUwNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e139696dcd5add32230bf32a2cff5063cc9110f6abcb1fd8371dc90050e8d6c7 |
| hovercard-subject-tag | issue:1076662660 |
| 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/21911/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9899b672822b4e3c91094fa02684f39246e07179d1e02e15f6bc028785b8e42d/matplotlib/matplotlib/issues/21911 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9899b672822b4e3c91094fa02684f39246e07179d1e02e15f6bc028785b8e42d/matplotlib/matplotlib/issues/21911 |
| og:image:alt | Problem Currently BoundaryNorm requires ncolors as an argument, and hence the user needs to know the colormap size to use it. Then we have this comment in the code # Mapping to the 0-1 interval cou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jklymak |
| 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