Title: autoinfer norms from scale names in the "norm" kwarg of imshow() and friends. · Issue #20746 · matplotlib/matplotlib · GitHub
Open Graph Title: autoinfer norms from scale names in the "norm" kwarg of imshow() and friends. · Issue #20746 · matplotlib/matplotlib
X Title: autoinfer norms from scale names in the "norm" kwarg of imshow() and friends. · Issue #20746 · matplotlib/matplotlib
Description: Problem Now that Norms are auto-derived from Scales (see make_norm_from_scale), it may be nice to reuse the scale-name machinery to allow using strings to specify norms, e.g. imshow(..., norm="log") # => norm=colors.make_norm_from_scale(...
Open Graph Description: Problem Now that Norms are auto-derived from Scales (see make_norm_from_scale), it may be nice to reuse the scale-name machinery to allow using strings to specify norms, e.g. imshow(..., norm="log"...
X Description: Problem Now that Norms are auto-derived from Scales (see make_norm_from_scale), it may be nice to reuse the scale-name machinery to allow using strings to specify norms, e.g. imshow(..., norm="...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/20746
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"autoinfer norms from scale names in the \"norm\" kwarg of imshow() and friends.","articleBody":"\u003c!--\r\nWelcome! Thanks for thinking of a way to improve Matplotlib.\r\n\r\n\r\nBefore creating a new feature request please search the issues for relevant feature requests.\r\n--\u003e\r\n\r\n### Problem\r\n\r\nNow that Norms are auto-derived from Scales (see `make_norm_from_scale`), it may be nice to reuse the scale-name machinery to allow using strings to specify norms, e.g.\r\n```python\r\nimshow(..., norm=\"log\")\r\n# =\u003e norm=colors.make_norm_from_scale(scale.scale_factory(\"log\"))\r\n# a.k.a. norm=colors.LogNorm()\r\n```\r\nand perhaps\r\n```python\r\nimshow(..., norm=(\"log\", vmin, vmax))\r\n```\r\nor just allow\r\n```python\r\nimshow(..., norm=\"log\", vmin=vmin, vmax=vmax)\r\n```\r\n(#15769 deprecated `norm=LogNorm(), vmin=vmin, vmax=vmax` but that was because in that case it was unclear whether the passed-in norm should be mutated, whereas here it's always a new norm instance which can thus always be mutated). (I'm not always particularly fond of using strings when objects would be more featureful, but here the machinery for scales is already present and well established so...)\r\n\r\nThis would seem relatively easy to implement, except for one detail: LogScale currently defaults to `nonpositive=\"clip\"` (see #9477 and the long tree of linked issues for the reason), whereas norms use `nonpositive=\"mask\"` (which is more or less implied by the existence of APIs like `Colormap.set_bad`). While this can be resolved in an ad-hoc manner (e.g. by making sure that such scales have a `nonpositive` parameter/attribute and setting it accordingly), I wonder whether a more general solution is possible.\r\n\r\n### Proposed Solution\r\n\r\nAs described above.\r\n\r\n### Additional context and prior art\r\n\r\n\u003c!-- Add any other context or screenshots about the feature request here. You can also include links to examples of other programs that have something similar to your request. For example:\r\n\r\n* Another project [...] solved this by [...]\r\n--\u003e\r\nAFAICT, proplot uses a hard-coded mapping of norm names (https://proplot.readthedocs.io/en/latest/api/proplot.constructor.Norm.html).","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2021-07-27T14:20:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/20746/matplotlib/issues/20746"}
| 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:ff840ac4-6ed1-c37f-fdb9-feb17c1826c5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BED0:371DAA:B1C038:B511C0:6A51260E |
| html-safe-nonce | 798029a53d5016ca8b2a526338054f5a5d74b9596614ff0415ccddd480f4093b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRUQwOjM3MURBQTpCMUMwMzg6QjUxMUMwOjZBNTEyNjBFIiwidmlzaXRvcl9pZCI6IjEzMTQwNDM1Nzk1NDc1OTIyMDYiLCJyZWdpb25fZWRnZSI6InNlYSIsInJlZ2lvbl9yZW5kZXIiOiJzZWEifQ== |
| visitor-hmac | ae3166fc9c90de2798832d07de9c814e620fef6ed6425f115ac29bfa2bca1be3 |
| hovercard-subject-tag | issue:953936368 |
| 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/20746/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0570bde4108f2135c08f227b0708430a0992e11171a80a19f7c655b162d87b2b/matplotlib/matplotlib/issues/20746 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0570bde4108f2135c08f227b0708430a0992e11171a80a19f7c655b162d87b2b/matplotlib/matplotlib/issues/20746 |
| og:image:alt | Problem Now that Norms are auto-derived from Scales (see make_norm_from_scale), it may be nice to reuse the scale-name machinery to allow using strings to specify norms, e.g. imshow(..., norm="log"... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 689b683944b0d7f015d0e776452c970832fa81b82dc15284469b556ecced715b |
| 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 | 942b51ed3bd5feee3d5e2719f890a5fe286edbbb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width