Title: [Bug]: colorbar with unattached mappables can't steal space · Issue #23709 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: colorbar with unattached mappables can't steal space · Issue #23709 · matplotlib/matplotlib
X Title: [Bug]: colorbar with unattached mappables can't steal space · Issue #23709 · matplotlib/matplotlib
Description: Bug summary This is something I noticed downstream in networkx: networkx/networkx#5937 (comment) Formerly, space for a Colorbar was stolen from the current Axes; that was deprecated and now in 3.6, it is stolen from the mappable's Axes. ...
Open Graph Description: Bug summary This is something I noticed downstream in networkx: networkx/networkx#5937 (comment) Formerly, space for a Colorbar was stolen from the current Axes; that was deprecated and now in 3.6,...
X Description: Bug summary This is something I noticed downstream in networkx: networkx/networkx#5937 (comment) Formerly, space for a Colorbar was stolen from the current Axes; that was deprecated and now in 3.6,...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/23709
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: colorbar with unattached mappables can't steal space","articleBody":"### Bug summary\r\n\r\nThis is something I noticed downstream in networkx: https://github.com/networkx/networkx/pull/5937#issuecomment-1223097369\r\n\r\nFormerly, space for a `Colorbar` was stolen from the current `Axes`; that was deprecated and now in 3.6, it is stolen from the mappable's `Axes`. But if the mappable is not added to an `Axes`, it fails with a somewhat unrelated-looking error.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib as mpl\r\nimport matplotlib.pyplot as plt\r\n\r\ncmap = plt.get_cmap('viridis')\r\n\r\npc = mpl.collections.PatchCollection([], cmap=cmap)\r\npc.set_array([])\r\n\r\nplt.colorbar(pc)\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n```pytb\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/home/elliott/code/matplotlib/lib/matplotlib/pyplot.py\", line 2053, in colorbar\r\n ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kwargs)\r\n File \"/home/elliott/code/matplotlib/lib/matplotlib/figure.py\", line 1260, in colorbar\r\n cax, kwargs = cbar.make_axes(ax, **kwargs)\r\n File \"/home/elliott/code/matplotlib/lib/matplotlib/colorbar.py\", line 1396, in make_axes\r\n fig = parents[0].get_figure()\r\nAttributeError: 'NoneType' object has no attribute 'get_figure'\r\n```\r\n\r\n### Expected outcome\r\n\r\nEither we should switch to the current Axes if the mappable doesn't have one (probably not desired given the previous change), or raise a clearer error message when this happens.\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\n_No response_\r\n\r\n### Matplotlib Version\r\n\r\n3.6.0rc1\r\n\r\n### Matplotlib Backend\r\n\r\n_No response_\r\n\r\n### Python version\r\n\r\n_No response_\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\npip","author":{"url":"https://github.com/QuLogic","@type":"Person","name":"QuLogic"},"datePublished":"2022-08-23T00:15:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/23709/matplotlib/issues/23709"}
| 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:3f0af9c4-8495-c2b4-865c-91caf187ddb2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E704:273DA9:26DC7A8:33F9F72:6A52160A |
| html-safe-nonce | 7f648d1ed577bd279318491009d4d5a4fd46b8958b7d031c7ab21afdab36d174 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzA0OjI3M0RBOToyNkRDN0E4OjMzRjlGNzI6NkE1MjE2MEEiLCJ2aXNpdG9yX2lkIjoiNjQwNTc4NTE4MzYzOTk2NzI0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d843906a91d44101ba21abac51c79eb5e908ba54ad3833a7bdafa78b74a59969 |
| hovercard-subject-tag | issue:1347148859 |
| 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/23709/issue_layout |
| twitter:image | https://opengraph.githubassets.com/36e52c49e58383f3732f2015beb5ab14406ffdcb97f907611277059962a46325/matplotlib/matplotlib/issues/23709 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/36e52c49e58383f3732f2015beb5ab14406ffdcb97f907611277059962a46325/matplotlib/matplotlib/issues/23709 |
| og:image:alt | Bug summary This is something I noticed downstream in networkx: networkx/networkx#5937 (comment) Formerly, space for a Colorbar was stolen from the current Axes; that was deprecated and now in 3.6,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | QuLogic |
| 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