Title: [Bug]: Colorbar cannot be added to another figure · Issue #25871 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Colorbar cannot be added to another figure · Issue #25871 · matplotlib/matplotlib
X Title: [Bug]: Colorbar cannot be added to another figure · Issue #25871 · matplotlib/matplotlib
Description: Bug summary Calling the colorbar method of one Figure object does not attach the colour bar to that figure, but to the one where the object informing the colour scale resides. Code for reproduction from matplotlib.pyplot import subplots ...
Open Graph Description: Bug summary Calling the colorbar method of one Figure object does not attach the colour bar to that figure, but to the one where the object informing the colour scale resides. Code for reproduction...
X Description: Bug summary Calling the colorbar method of one Figure object does not attach the colour bar to that figure, but to the one where the object informing the colour scale resides. Code for reproduction...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25871
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Colorbar cannot be added to another figure","articleBody":"### Bug summary\r\n\r\nCalling the `colorbar` method of one `Figure` object does not attach the colour bar to that figure, but to the one where the object informing the colour scale resides.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nfrom matplotlib.pyplot import subplots\r\nimport numpy as np\r\n\r\nfig1, axes1 = subplots()\r\nfig2, axes2 = subplots()\r\nfig1.suptitle(\"Figure 1\")\r\nfig2.suptitle(\"Figure 2\")\r\nimage1 = axes1.imshow(np.random.random((9,9)))\r\nimage2 = axes2.imshow(np.random.random((9,9)))\r\nfig2.colorbar(image1)\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\nThe colour bar gets attached to Image 1:\r\n\r\n \r\n\r\n### Expected outcome\r\n\r\nThe colour bar should get attached to Image 2. At the very least there should be an error.\r\n\r\n### Matplotlib Version\r\n\r\n3.7.1\r\n\r\n### Installation\r\n\r\npip","author":{"url":"https://github.com/Wrzlprmft","@type":"Person","name":"Wrzlprmft"},"datePublished":"2023-05-12T18:50:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/25871/matplotlib/issues/25871"}
| 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:caeddab9-3f45-c811-198c-fa18db4931ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4BA:223B79:1413B8:1B8334:6A5252B9 |
| html-safe-nonce | 63cb432c1cd53026f4f53e081aa7b9446d835b600b0516ed9834507dbc5b6e41 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEJBOjIyM0I3OToxNDEzQjg6MUI4MzM0OjZBNTI1MkI5IiwidmlzaXRvcl9pZCI6IjkyMDE5Njk5ODM1NDg1MDQ4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b917bea8c4af6f2f85952e434ec5f09039699ec5fa88265867dcf8e1b1f2d583 |
| hovercard-subject-tag | issue:1708062213 |
| 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/25871/issue_layout |
| twitter:image | https://opengraph.githubassets.com/608bdf3d91690684dc2fb8ce03801952a8ef52bc53d4e1567c526c635812bbf6/matplotlib/matplotlib/issues/25871 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/608bdf3d91690684dc2fb8ce03801952a8ef52bc53d4e1567c526c635812bbf6/matplotlib/matplotlib/issues/25871 |
| og:image:alt | Bug summary Calling the colorbar method of one Figure object does not attach the colour bar to that figure, but to the one where the object informing the colour scale resides. Code for reproduction... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Wrzlprmft |
| 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