Title: [Bug]: Axes.label_outer() does not work when there is a colorbar · Issue #27305 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Axes.label_outer() does not work when there is a colorbar · Issue #27305 · matplotlib/matplotlib
X Title: [Bug]: Axes.label_outer() does not work when there is a colorbar · Issue #27305 · matplotlib/matplotlib
Description: Bug summary Axes.label_outer() fails to hide axis and tick labels for plots that have a colorbar. Code for reproduction import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) fig, axs = p...
Open Graph Description: Bug summary Axes.label_outer() fails to hide axis and tick labels for plots that have a colorbar. Code for reproduction import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np....
X Description: Bug summary Axes.label_outer() fails to hide axis and tick labels for plots that have a colorbar. Code for reproduction import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np....
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/27305
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Axes.label_outer() does not work when there is a colorbar","articleBody":"### Bug summary\n\n`Axes.label_outer()` fails to hide axis and tick labels for plots that have a colorbar.\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\nx = np.linspace(0, 2 * np.pi, 400)\r\ny = np.sin(x ** 2)\r\n\r\nfig, axs = plt.subplots(2, 2)\r\naxs[0, 0].plot(x, y)\r\ncl2c = axs[0, 1].scatter(x, y, c=x)\r\nfig.colorbar(cl2c, ax=axs[0, 1], label='c-label')\r\naxs[1, 0].plot(x, y)\r\naxs[1, 1].plot(x, y)\r\n\r\nfor ax in axs.flat:\r\n ax.set(xlabel='x-label', ylabel='y-label')\r\n\r\n# try to hide x labels and tick labels for top plots and y ticks for right plots,\r\n# but this fails to hide the labels for axs[0, 1] due to its colorbar\r\nfor ax in axs.flat:\r\n ax.label_outer()\n```\n\n\n### Actual outcome\n\nThe output of the code above gives:\r\n\r\n\n\n### Expected outcome\n\nI would have expected the plot to look like:\r\n\r\n\r\n\r\nThis expected plot was created by creating the colorbar after the `ax.label_outer()` calls. However, I would not have expected this to have affected whether the labels/ticks are removed.\r\n\r\n```python\r\nfig, axs = plt.subplots(2, 2)\r\naxs[0, 0].plot(x, y)\r\ncl2c = axs[0, 1].scatter(x, y, c=x)\r\naxs[1, 0].plot(x, y)\r\naxs[1, 1].plot(x, y)\r\n\r\nfor ax in axs.flat:\r\n ax.set(xlabel='x-label', ylabel='y-label')\r\n\r\n# Hide x labels and tick labels for top plots and y ticks for right plots.\r\nfor ax in axs.flat:\r\n ax.label_outer()\r\n\r\nfig.colorbar(cl2c, ax=axs[0, 1], label='c-label')\r\n\r\nfig.tight_layout()\r\n```\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nUbuntu 20.04.5 LTS\n\n### Matplotlib Version\n\n3.8.0\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\nPython 3.11.6\n\n### Jupyter version\n\n7.0.6\n\n### Installation\n\nconda","author":{"url":"https://github.com/chrisyeh96","@type":"Person","name":"chrisyeh96"},"datePublished":"2023-11-10T18:42:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/27305/matplotlib/issues/27305"}
| 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:f8db712a-4bdc-0f48-5ea3-96453cfcd52d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C906:2D422D:6C4A08:8FB391:6A51D3D3 |
| html-safe-nonce | b8b10887af88673240a74fd06fa865424b7d5c43e2ceefc855f9fc5b8526c5ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTA2OjJENDIyRDo2QzRBMDg6OEZCMzkxOjZBNTFEM0QzIiwidmlzaXRvcl9pZCI6Ijc2NjA3MjU2OTQ5Njg3NDY5NjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7548d28fc5f15aa12f65ed6ef6c87e10e8d05ae93a3f56ff4216264a3ee0e81e |
| hovercard-subject-tag | issue:1988167250 |
| 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/27305/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8a3cc43e7ff561c4a4708ba49a60e6bdb319514834c8c3e0fd05603e3f9fa439/matplotlib/matplotlib/issues/27305 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8a3cc43e7ff561c4a4708ba49a60e6bdb319514834c8c3e0fd05603e3f9fa439/matplotlib/matplotlib/issues/27305 |
| og:image:alt | Bug summary Axes.label_outer() fails to hide axis and tick labels for plots that have a colorbar. Code for reproduction import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chrisyeh96 |
| 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