Title: [Bug]: Colormap + NoNorm only plots one color under `matplotlib` 3.5.0 · Issue #21870 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Colormap + NoNorm only plots one color under `matplotlib` 3.5.0 · Issue #21870 · matplotlib/matplotlib
X Title: [Bug]: Colormap + NoNorm only plots one color under `matplotlib` 3.5.0 · Issue #21870 · matplotlib/matplotlib
Description: Bug summary My aim is to plot a colormap with e.g. 5 discrete colors (with 5 ticks centered per color). Under matplotlib 3.4.3, I got this working with the code snippet below using NoNorm; under 3.5.0, only one color is plotted. Is this ...
Open Graph Description: Bug summary My aim is to plot a colormap with e.g. 5 discrete colors (with 5 ticks centered per color). Under matplotlib 3.4.3, I got this working with the code snippet below using NoNorm; under 3....
X Description: Bug summary My aim is to plot a colormap with e.g. 5 discrete colors (with 5 ticks centered per color). Under matplotlib 3.4.3, I got this working with the code snippet below using NoNorm; under 3....
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21870
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Colormap + NoNorm only plots one color under `matplotlib` 3.5.0","articleBody":"### Bug summary\n\nMy aim is to plot a colormap with e.g. 5 discrete colors (with 5 ticks centered per color).\r\n\r\nUnder `matplotlib` 3.4.3, I got this working with the code snippet below using `NoNorm`; under 3.5.0, only one color is plotted.\r\n\r\nIs this a bug - or is my setup incorrect/unidiomatic and worked only by chance before?\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\nfrom matplotlib import cm, colors\r\n\r\ndata = [1, 2, 3, 4, 5]\r\n\r\nfig, ax = plt.subplots(figsize=(6, 1))\r\nfig.subplots_adjust(bottom=0.5)\r\n\r\nnorm = colors.NoNorm(vmin=min(data), vmax=max(data))\r\ncmap = cm.get_cmap(\"viridis\", len(data))\r\ncbar = fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), cax=ax, orientation=\"horizontal\")\r\nprint(cbar.get_ticks())\n```\n\n\n### Actual outcome\n\n\r\n\r\nThis _is_ the output under `matplotlib` 3.5.0.\n\n### Expected outcome\n\n\r\n\r\nThis _was_ the output under `matplotlib` 3.4.3.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nUbuntu\n\n### Matplotlib Version\n\n3.5.0\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\nPython 3.9.7\n\n### Jupyter version\n\n3.2.4\n\n### Installation\n\nconda","author":{"url":"https://github.com/dominiquesydow","@type":"Person","name":"dominiquesydow"},"datePublished":"2021-12-05T21:50:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/21870/matplotlib/issues/21870"}
| 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:8182b8ce-0b2f-debc-77d6-675596ea1070 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B192:2F83DE:EDC2B:13C61B:6A52E1FE |
| html-safe-nonce | ca1069e0545ec102114851de53e8525cfd71bb6049928c4f0e2d5a40154a83a3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTkyOjJGODNERTpFREMyQjoxM0M2MUI6NkE1MkUxRkUiLCJ2aXNpdG9yX2lkIjoiMjM1ODYxMjAyNzE2ODE4Njg3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4862ffb51705dc8a0492abdcdec0bce92e3bf5aecc98357989558af752a82db7 |
| hovercard-subject-tag | issue:1071566741 |
| 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/21870/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d7dc818024cdd2d8799fcf583c885689395c8357e21194ec44989d947f091b18/matplotlib/matplotlib/issues/21870 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d7dc818024cdd2d8799fcf583c885689395c8357e21194ec44989d947f091b18/matplotlib/matplotlib/issues/21870 |
| og:image:alt | Bug summary My aim is to plot a colormap with e.g. 5 discrete colors (with 5 ticks centered per color). Under matplotlib 3.4.3, I got this working with the code snippet below using NoNorm; under 3.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dominiquesydow |
| 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