Title: [Bug]: Axes.cla() with sharex may wrongly reset the axes limit. · Issue #27825 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Axes.cla() with sharex may wrongly reset the axes limit. · Issue #27825 · matplotlib/matplotlib
X Title: [Bug]: Axes.cla() with sharex may wrongly reset the axes limit. · Issue #27825 · matplotlib/matplotlib
Description: Bug summary For example, when subplot A shares the x-axis with subplot B (A is created with sharex=B), a call to B.cla() will set the xlimit to [0, 1], which may not be expected (in contrast, a call to A.cla() will not change the xlimit)...
Open Graph Description: Bug summary For example, when subplot A shares the x-axis with subplot B (A is created with sharex=B), a call to B.cla() will set the xlimit to [0, 1], which may not be expected (in contrast, a cal...
X Description: Bug summary For example, when subplot A shares the x-axis with subplot B (A is created with sharex=B), a call to B.cla() will set the xlimit to [0, 1], which may not be expected (in contrast, a cal...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/27825
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Axes.cla() with sharex may wrongly reset the axes limit.","articleBody":"### Bug summary\n\nFor example, when subplot A shares the x-axis with subplot B (A is created with sharex=B), a call to `B.cla()` will set the xlimit to [0, 1], which may not be expected (in contrast, a call to `A.cla()` will not change the xlimit).\r\n\r\nI think the main problem comes from the following function, where it will check whether its `_sharex` attribute is `None`; however, in this case, B is shared to A, but no axis is shared to B, so B's `_sharex` attribute is `None`.\r\nhttps://github.com/matplotlib/matplotlib/blob/9e18a343fb58a2978a8e27df03190ed21c61c343/lib/matplotlib/axes/_base.py#L1369 \n\n### Code for reproduction\n\n```Python\nax = plt.subplot(211)\r\nax2 = plt.subplot(212, sharex=ax)\r\nax.plot(range(50))\r\nax2.plot(range(50))\r\nax.cla()\r\nplt.show()\n```\n\n\n### Actual outcome\n\n\r\n\n\n### Expected outcome\n\n\r\n\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.8.3\n\n### Matplotlib Backend\n\n'TkAgg'\n\n### Python version\n\n3.9.13\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/tianzhuqiao","@type":"Person","name":"tianzhuqiao"},"datePublished":"2024-02-27T02:13:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/27825/matplotlib/issues/27825"}
| 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:b2b9bb08-0f11-f845-5f14-6107dccb0f61 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E6F2:23560F:A98C9A:E50B08:6A5315B7 |
| html-safe-nonce | 46fdbe38dcce7fdb0df24ccf04bedffe16f70f5896d0e4cde3ec4cf1207a77b2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNkYyOjIzNTYwRjpBOThDOUE6RTUwQjA4OjZBNTMxNUI3IiwidmlzaXRvcl9pZCI6IjQ1NzE2NzA1NjE1MzM2NjI2NDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b422065a9e0477fe39a749c65c733d7c95bcbbb8b7c755069d292852d36cf5bb |
| hovercard-subject-tag | issue:2155505674 |
| 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/27825/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7cc10cb0a71dd02edb3bc68612351c9009af3099d3727c148eff52f45fc9cd1d/matplotlib/matplotlib/issues/27825 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7cc10cb0a71dd02edb3bc68612351c9009af3099d3727c148eff52f45fc9cd1d/matplotlib/matplotlib/issues/27825 |
| og:image:alt | Bug summary For example, when subplot A shares the x-axis with subplot B (A is created with sharex=B), a call to B.cla() will set the xlimit to [0, 1], which may not be expected (in contrast, a cal... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tianzhuqiao |
| 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