Title: [Bug]: pcolormesh's default x/y range might break `set_scale('log')` · Issue #29615 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: pcolormesh's default x/y range might break `set_scale('log')` · Issue #29615 · matplotlib/matplotlib
X Title: [Bug]: pcolormesh's default x/y range might break `set_scale('log')` · Issue #29615 · matplotlib/matplotlib
Description: Bug summary While using pcolormesh, setting the x- or y-scale to logarithmic sometimes breaks. It turned out this happens when the default x/ylim contain negative values. A fix could be to ensure that limits are all positive before calli...
Open Graph Description: Bug summary While using pcolormesh, setting the x- or y-scale to logarithmic sometimes breaks. It turned out this happens when the default x/ylim contain negative values. A fix could be to ensure t...
X Description: Bug summary While using pcolormesh, setting the x- or y-scale to logarithmic sometimes breaks. It turned out this happens when the default x/ylim contain negative values. A fix could be to ensure t...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29615
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: pcolormesh's default x/y range might break `set_scale('log')`","articleBody":"### Bug summary\n\nWhile using `pcolormesh`, setting the x- or y-scale to logarithmic sometimes breaks. It turned out this happens when the default `x/ylim` contain negative values. A fix could be to ensure that limits are all positive before calling the `set_x/yscale('log')`. \n\nThis likely happens with similar commands as well. \n\n### Code for reproduction\n\n```Python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nx = np.arange(4, dtype=float)\ny = np.linspace(1e1, 1e5, 10) # all positive\nz = np.arange(len(x)*len(y)).reshape(len(x), len(y))\n\nfig, axs = plt.subplots(1,3, figsize=(9,3))\n\n# works fine\naxs[0].pcolormesh(x,y, z.T)\n\n# doesn't work fine\naxs[1].pcolormesh(x,y, z.T)\naxs[1].set_yscale('log') # because the limits set automatically include negative values \n\n# works fine\naxs[2].pcolormesh(x,y, z.T)\naxs[2].set_ylim(1e-3, y.max()) # Fix: we can explicitly set limits to the positive range \naxs[2].set_yscale('log')\n```\n\n### Actual outcome\n\n\n\n### Expected outcome\n\nThe rightmost plot is the expected outcome, whereas the middle panel is what will be output by default.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nUbuntu 22.04.5 LTS\n\n### Matplotlib Version\n\n3.8.4\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.12.3\n\n### Jupyter version\n\n4.2.5\n\n### Installation\n\nconda","author":{"url":"https://github.com/arashgmn","@type":"Person","name":"arashgmn"},"datePublished":"2025-02-13T14:00:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/29615/matplotlib/issues/29615"}
| 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:195adac6-b1ba-d64d-b2ce-3c6a8954d49a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9216:3FC474:6C0210:9B71CB:6A5490D8 |
| html-safe-nonce | 6e95dae603ee0802bad6e7db5b6fc88b1163a6794286e7db2089280ed73736d3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjE2OjNGQzQ3NDo2QzAyMTA6OUI3MUNCOjZBNTQ5MEQ4IiwidmlzaXRvcl9pZCI6IjUxMTYzMDgyMzAzOTg4NDEwNDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b06bd8a948250a9d056173ad685b1cdb457b72e68484fb3b7c9cb1ca866fb96b |
| hovercard-subject-tag | issue:2851127977 |
| 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/29615/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8ce4593b4036b9b2fa84bbf8638ea305410ac60958b0544850ba27bfbdbd4a70/matplotlib/matplotlib/issues/29615 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8ce4593b4036b9b2fa84bbf8638ea305410ac60958b0544850ba27bfbdbd4a70/matplotlib/matplotlib/issues/29615 |
| og:image:alt | Bug summary While using pcolormesh, setting the x- or y-scale to logarithmic sometimes breaks. It turned out this happens when the default x/ylim contain negative values. A fix could be to ensure t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | arashgmn |
| 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 | f8cfff6384f62259baea531c7f58bc7040f8dd92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width