Title: [Bug]: ValueError: Unable to determine Axes to steal space for Colorbar. · Issue #23973 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: ValueError: Unable to determine Axes to steal space for Colorbar. · Issue #23973 · matplotlib/matplotlib
X Title: [Bug]: ValueError: Unable to determine Axes to steal space for Colorbar. · Issue #23973 · matplotlib/matplotlib
Description: Bug summary matplotlib==3.6.0 started raising an error when trying to add a colorbar to plt.hist(): ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument to use as the Axes for the Colorbar, pr...
Open Graph Description: Bug summary matplotlib==3.6.0 started raising an error when trying to add a colorbar to plt.hist(): ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument...
X Description: Bug summary matplotlib==3.6.0 started raising an error when trying to add a colorbar to plt.hist(): ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/23973
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: ValueError: Unable to determine Axes to steal space for Colorbar.","articleBody":"### Bug summary\r\n\r\n`matplotlib==3.6.0` started raising an error when trying to add a colorbar to `plt.hist()`:\r\n\r\nValueError: Unable to determine Axes to steal space for Colorbar. Either provide the *cax* argument to use as the Axes for the Colorbar, provide the *ax* argument to steal space from it, or add *mappable* to an Axes.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\nxs = np.random.rand(100)\r\n\r\n_, bin_edges, bars = plt.hist(xs)\r\ncolor_map = getattr(plt.cm, \"hot\")\r\nfor x_val, rect in zip(bin_edges, bars.patches):\r\n rect.set_color(color_map(x_val))\r\n\r\ncbar = plt.colorbar(\r\n plt.cm.ScalarMappable(cmap=color_map),\r\n # cax=ax.inset_axes([0.95, 0.1, 0.05, 0.8]),\r\n)\r\n```\r\n\r\n### Actual outcome\r\n\r\nIn `matplotlib==3.6.0`:\r\n\r\n\r\n\r\n\r\n### Expected outcome\r\n\r\nIn `matplotlib==3.5.1`:\r\n\r\n\r\n\r\n### Operating system\r\n\r\nmacOS 12.6\r\n\r\n### Matplotlib Version\r\n\r\n3.6.0\r\n\r\n### Python version\r\n\r\n3.10\r\n\r\n### Installation\r\n\r\npip","author":{"url":"https://github.com/janosh","@type":"Person","name":"janosh"},"datePublished":"2022-09-21T15:37:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/23973/matplotlib/issues/23973"}
| 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:0f61595e-01c2-066b-2aea-690e6b8e02de |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB4C:1F29:491FFFC:65D8CD5:6A50F6ED |
| html-safe-nonce | 4c7c427ee1b884a8e57fff7fcb942977b86ba7d8eb316b9b818969a5cbe14514 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjRDOjFGMjk6NDkxRkZGQzo2NUQ4Q0Q1OjZBNTBGNkVEIiwidmlzaXRvcl9pZCI6IjgxMjU3NzgxODY3NzQ1NzQ4MjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5e557bcc53a47df56748a1d1d8eaa3ac04356d17fc29e472ed80aa8056bf5793 |
| hovercard-subject-tag | issue:1381135960 |
| 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/23973/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ea8df489276cab041c725273b985c52e29bdcc034288c42da530db8d7c8b130d/matplotlib/matplotlib/issues/23973 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ea8df489276cab041c725273b985c52e29bdcc034288c42da530db8d7c8b130d/matplotlib/matplotlib/issues/23973 |
| og:image:alt | Bug summary matplotlib==3.6.0 started raising an error when trying to add a colorbar to plt.hist(): ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | janosh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838 |
| 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 | 8d836581d020676cc0ef4a83cd2fe17e4af02c3d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width