Title: [Bug]: Calling axes.clear() on a shared y or x-axis issues an unexpected warning with log scale · Issue #30159 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Calling axes.clear() on a shared y or x-axis issues an unexpected warning with log scale · Issue #30159 · matplotlib/matplotlib
X Title: [Bug]: Calling axes.clear() on a shared y or x-axis issues an unexpected warning with log scale · Issue #30159 · matplotlib/matplotlib
Description: Bug summary Hi everyone, I somehow created a plot in unorthodox order, i.e. first plot some data in the second column, then in the first one. To generate my plots, I call a method that automatically clears the axes sets the scale sets th...
Open Graph Description: Bug summary Hi everyone, I somehow created a plot in unorthodox order, i.e. first plot some data in the second column, then in the first one. To generate my plots, I call a method that automaticall...
X Description: Bug summary Hi everyone, I somehow created a plot in unorthodox order, i.e. first plot some data in the second column, then in the first one. To generate my plots, I call a method that automaticall...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30159
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Calling axes.clear() on a shared y or x-axis issues an unexpected warning with log scale","articleBody":"### Bug summary\n\nHi everyone,\n\nI somehow created a plot in unorthodox order, i.e. first plot some data in the second column, then in the first one. To generate my plots, I call a method that automatically\n\n- clears the axes\n- sets the scale\n- sets the limits\n- plots the data\n\nIn this case two warnings are issued. The code of the minimal example reproduces this behavior. When changing it to the second variant in the code block (first plotting the first column, then the second column) the issue disappears.\n\nThank you!\n\nBest\n\nFrancesco\n\n### Code for reproduction\n\n```Python\nimport numpy as np\nfrom matplotlib import pyplot as plt\n\n\n# ISSUE ARISES IN THIS VARIANT\nfig, ax = plt.subplots(1, 2, sharey=True)\n\n\nax[1].scatter(np.random.randint(1, 100, 100), np.random.randint(1, 100, 100))\nax[1].set_yscale(\"log\")\nax[1].set_ylim([1e0, 1e2])\n\nax[0].clear()\nax[0].scatter(np.random.randint(1, 100, 100), np.random.randint(1, 100, 100))\n\nplt.show()\n\n# NO ISSUE IN THE VARIANT BELOW\nimport numpy as np\nfrom matplotlib import pyplot as plt\n\n\nfig, ax = plt.subplots(1, 2, sharey=True)\n\n\nax[0].scatter(np.random.randint(1, 100, 100), np.random.randint(1, 100, 100))\nax[0].set_yscale(\"log\")\nax[0].set_ylim([1e0, 1e2])\n\nax[1].clear()\nax[1].scatter(np.random.randint(1, 100, 100), np.random.randint(1, 100, 100))\n\nplt.show()\n```\n\n### Actual outcome\n\nFutureWarning: Attempt to set non-positive ylim on a log-scaled axis will be ignored.\nFutureWarning: Attempting to set identical low and high ylims makes transformation singular; automatically expanding.\n\n### Expected outcome\n\nNo warning is issued\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nWindows\n\n### Matplotlib Version\n\n3.10.0\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.11.11\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/fwitte","@type":"Person","name":"fwitte"},"datePublished":"2025-06-10T13:50:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/30159/matplotlib/issues/30159"}
| 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:676e9dd7-90c3-7324-795a-98d1cf095608 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95A4:25C27F:5EF7A9:7E0D00:6A52693D |
| html-safe-nonce | 2ab6390d126a2e007e799bdf50337e9978a1d87018d0483856fb6e87fbc5f5aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUE0OjI1QzI3Rjo1RUY3QTk6N0UwRDAwOjZBNTI2OTNEIiwidmlzaXRvcl9pZCI6IjQ5NzkyOTgxMzgwMDExNDAwMjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0ec5ff511a401fe740dba94000079d94bd5260b385771ec7c4dd8f1e2e8483e6 |
| hovercard-subject-tag | issue:3133687818 |
| 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/30159/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3050650290dbd59aeb44f10d4e2a753be2d3162e82d0f72b0006bbedbd040711/matplotlib/matplotlib/issues/30159 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3050650290dbd59aeb44f10d4e2a753be2d3162e82d0f72b0006bbedbd040711/matplotlib/matplotlib/issues/30159 |
| og:image:alt | Bug summary Hi everyone, I somehow created a plot in unorthodox order, i.e. first plot some data in the second column, then in the first one. To generate my plots, I call a method that automaticall... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fwitte |
| 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