Title: [Bug]: Wrong scaling of `NonUniformImage` with logarithmic axes · Issue #29368 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Wrong scaling of `NonUniformImage` with logarithmic axes · Issue #29368 · matplotlib/matplotlib
X Title: [Bug]: Wrong scaling of `NonUniformImage` with logarithmic axes · Issue #29368 · matplotlib/matplotlib
Description: Bug summary I'm trying to produce a density plot of logarithmically spaced data. Using NonUniformImage used to work before matplotlib version 3.10, where I know exhibit a weirdly scaled axis. Code for reproduction import numpy as np impo...
Open Graph Description: Bug summary I'm trying to produce a density plot of logarithmically spaced data. Using NonUniformImage used to work before matplotlib version 3.10, where I know exhibit a weirdly scaled axis. Code ...
X Description: Bug summary I'm trying to produce a density plot of logarithmically spaced data. Using NonUniformImage used to work before matplotlib version 3.10, where I know exhibit a weirdly scaled axis. C...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29368
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Wrong scaling of `NonUniformImage` with logarithmic axes","articleBody":"### Bug summary\n\nI'm trying to produce a density plot of logarithmically spaced data. Using `NonUniformImage` used to work before matplotlib version `3.10`, where I know exhibit a weirdly scaled axis.\n\n### Code for reproduction\n\n```Python\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.image import NonUniformImage\r\n\r\nx = np.linspace(0, 1, 2)\r\ny = np.geomspace(1e1, 1e5, 3)\r\nz = np.random.uniform(size=(len(x), len(y)))\r\n\r\n_, (ax1, ax2) = plt.subplots(ncols=2)\r\n\r\n# create the non-uniform image\r\nim = NonUniformImage(ax1, extent=[0, 1, 1e0, 1e6], origin=\"lower\")\r\nim.set_data(x, y, z.T)\r\nax1.add_image(im)\r\nax1.set_yscale(\"log\")\r\nax1.set_ylim(1e0, 1e6) # omitting this leads to very weird behavior\r\nax1.set_title(\"NonUniformImage\")\r\n\r\n# use pcolormesh to get reference image\r\nax2.pcolormesh([0, 0.5, 1], [1e0, 1e2, 1e4, 1e6], z.T)\r\nax2.set_yscale(\"log\")\r\nax2.set_title(\"pcolormesh\")\n```\n\n\n### Actual outcome\n\nThe code above produces the following image\r\n\r\n\r\n\n\n### Expected outcome\n\nI expect the left panel to look like the right panel, which was produced using `pcolormesh`. The reason I don't want to use `pcolormesh` for these plots is that the quality in PDFs is often much worse (with lines showing up between patches) and the file size can easily be 10 times larger.\n\n### Additional information\n\nI recently asked [a related question on Stackoverflow](https://stackoverflow.com/q/79261313/932593), which has some additional details.\n\n### Operating system\n\nOS/X\n\n### Matplotlib Version\n\n3.10.0\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.12.8\n\n### Jupyter version\n\n7.3.1\n\n### Installation\n\nconda","author":{"url":"https://github.com/david-zwicker","@type":"Person","name":"david-zwicker"},"datePublished":"2024-12-21T12:50:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/29368/matplotlib/issues/29368"}
| 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:792b8534-2b28-8fba-f937-5f9dd8fb18fd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A9EA:1D4F69:2257CDE:2E9A10C:6A53936F |
| html-safe-nonce | 298a84d2f67d7a68bef7ba36a2f8f22e55bcd521168f184d067cba276c9f6aba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUVBOjFENEY2OToyMjU3Q0RFOjJFOUExMEM6NkE1MzkzNkYiLCJ2aXNpdG9yX2lkIjoiNTU5OTkzMDExMjA5MzE2NDM5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 92dca927f721363ce82e2d862642660068c49869976b64f5828efc9bdae48d7b |
| hovercard-subject-tag | issue:2753995590 |
| 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/29368/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c5086aacc828b2c8adc9c4b0c3ef053709db4b42ddd341d4da24d62e1f890905/matplotlib/matplotlib/issues/29368 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c5086aacc828b2c8adc9c4b0c3ef053709db4b42ddd341d4da24d62e1f890905/matplotlib/matplotlib/issues/29368 |
| og:image:alt | Bug summary I'm trying to produce a density plot of logarithmically spaced data. Using NonUniformImage used to work before matplotlib version 3.10, where I know exhibit a weirdly scaled axis. Code ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | david-zwicker |
| 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