Title: imshow with LogNorm crashes with certain inputs · Issue #18415 · matplotlib/matplotlib · GitHub
Open Graph Title: imshow with LogNorm crashes with certain inputs · Issue #18415 · matplotlib/matplotlib
X Title: imshow with LogNorm crashes with certain inputs · Issue #18415 · matplotlib/matplotlib
Description: Bug report Bug summary Due to changes introduced in 3dea5c7, trying to display some images with LogNorm will crash because vmin gets auto-adjusted to 0 (which is invalid for LogNorm). Code for reproduction import numpy as np import matpl...
Open Graph Description: Bug report Bug summary Due to changes introduced in 3dea5c7, trying to display some images with LogNorm will crash because vmin gets auto-adjusted to 0 (which is invalid for LogNorm). Code for repr...
X Description: Bug report Bug summary Due to changes introduced in 3dea5c7, trying to display some images with LogNorm will crash because vmin gets auto-adjusted to 0 (which is invalid for LogNorm). Code for repr...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/18415
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"imshow with LogNorm crashes with certain inputs","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\n\r\nDue to changes introduced in 3dea5c7, trying to display some images with LogNorm will crash because vmin gets auto-adjusted to 0 (which is invalid for LogNorm).\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\n\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.colors import LogNorm\r\n\r\ndata = np.full((500, 500), -1, dtype=np.float64)\r\ndata[0:250, :] = 1E20\r\n\r\nfig, ax = plt.subplots()\r\nim = ax.imshow(data, norm=LogNorm(vmin=100, vmax=data.max()))\r\n\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n```\r\n File \"C:\\Python38\\lib\\site-packages\\matplotlib\\image.py\", line 922, in make_image\r\n return self._make_image(self._A, bbox, transformed_bbox, clip,\r\n File \"C:\\Python38\\lib\\site-packages\\matplotlib\\image.py\", line 541, in _make_image\r\n output = self.norm(resampled_masked)\r\n File \"C:\\Python38\\lib\\site-packages\\matplotlib\\colors.py\", line 1193, in __call__\r\n self._check_vmin_vmax()\r\n File \"C:\\Python38\\lib\\site-packages\\matplotlib\\colors.py\", line 1182, in _check_vmin_vmax\r\n raise ValueError(\"minvalue must be positive\")\r\nValueError: minvalue must be positive\r\n```\r\n\r\n**Expected outcome**\r\n\r\nShowed a plot in MPL 3.1 (and I believe every version until 3.3). The crash is coming from _make_image transforming vmin to be zero per changes added in 3dea5c7. I guess perhaps the solution is \"then don't try to plot that, use a vmin closer to your vmax\" but kind of inconvenient for code that previously worked fine.\r\n\r\n**Matplotlib version**: 3.3.1","author":{"url":"https://github.com/LevN0","@type":"Person","name":"LevN0"},"datePublished":"2020-09-06T18:05:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/18415/matplotlib/issues/18415"}
| 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:8e49e6e4-fd2a-3e0f-67a9-246ad710eba0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B166:1F2FB0:1CF2573:264662D:6A52D7FA |
| html-safe-nonce | 87d96ca579e5b4cbe807bb3cdf6a652ecc743729edafe84f7495bafd5a1205d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTY2OjFGMkZCMDoxQ0YyNTczOjI2NDY2MkQ6NkE1MkQ3RkEiLCJ2aXNpdG9yX2lkIjoiMjI2MTY0MjEzMjQ1OTgwNDY2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fdc8f743efa1fa17f8853bc5a1536e223194114f736afd0995da4f54eb4c28d8 |
| hovercard-subject-tag | issue:694472111 |
| 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/18415/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4c5078214080a4aaa662737a258e52420370aa40c512e2689a9b467639ce8078/matplotlib/matplotlib/issues/18415 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c5078214080a4aaa662737a258e52420370aa40c512e2689a9b467639ce8078/matplotlib/matplotlib/issues/18415 |
| og:image:alt | Bug report Bug summary Due to changes introduced in 3dea5c7, trying to display some images with LogNorm will crash because vmin gets auto-adjusted to 0 (which is invalid for LogNorm). Code for repr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LevN0 |
| 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