Title: BUG: Contours with LogNorm · Issue #19856 · matplotlib/matplotlib · GitHub
Open Graph Title: BUG: Contours with LogNorm · Issue #19856 · matplotlib/matplotlib
X Title: BUG: Contours with LogNorm · Issue #19856 · matplotlib/matplotlib
Description: Bug report Bug summary Contour plots don't interact nicely with matplotlib.colors.LogNorm. Likely related to #19748 Code for reproduction import matplotlib.pyplot as plt from matplotlib.colors import LogNorm import numpy as np # BUG: set...
Open Graph Description: Bug report Bug summary Contour plots don't interact nicely with matplotlib.colors.LogNorm. Likely related to #19748 Code for reproduction import matplotlib.pyplot as plt from matplotlib.colors impo...
X Description: Bug report Bug summary Contour plots don't interact nicely with matplotlib.colors.LogNorm. Likely related to #19748 Code for reproduction import matplotlib.pyplot as plt from matplotlib.colors ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19856
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BUG: Contours with LogNorm","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\nContour plots don't interact nicely with `matplotlib.colors.LogNorm`.\r\nLikely related to #19748\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.colors import LogNorm\r\nimport numpy as np\r\n\r\n# BUG: setting levels as a scalar has no effect and no warning or error is printed\r\nfig, ax = plt.subplots()\r\nim = ax.contourf(x, y, data, norm=LogNorm(), levels=4)\r\nfig.colorbar(im, ax=ax)\r\nplt.show()\r\n```\r\n\r\n\r\n\r\n```python\r\n# kinda buggy too: setting levels as an array does have some of the desired effects\r\n# but ticks and ticklabels are incorrect\r\nfig, ax = plt.subplots()\r\nlevels = np.logspace(np.log10(data.min()), np.log10(data.max()), 5)\r\nim = ax.contourf(x, y, data, norm=LogNorm(), levels=levels)\r\nfig.colorbar(im, ax=ax)\r\nplt.show()\r\n```\r\n\r\n\r\n\r\n\r\n**Expected outcome**\r\n\r\nThe experience should be comparable with what happens when the norm isn't specified: the `levels` kwarg should be usable in both cases.\r\nI note that the output from the first snippet is consistent with the case where neither `levels` or `norm` are specified, and is correct in that case, so it's definetely not _completely broken_ and I hope the fix is somewhat straightforward.\r\n\r\nI'm happy to take a look at the source and see if I can come up with an easy patch, but I'm not sure when I'll have time to dive in there myself. Any piece advice from maintainers or contributors is more than welcome !\r\n\r\n**Matplotlib version**\r\n\r\n * Operating system: MacOS\r\n * Matplotlib version (`import matplotlib; print(matplotlib.__version__)`): 3.4.1\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): `module://ipykernel.pylab.backend_inline`\r\n * Python version: 3.9.1\r\n * Jupyter version (if applicable): NA\r\n * Other libraries: \r\n\r\nI installed matplotlib using pip.","author":{"url":"https://github.com/neutrinoceros","@type":"Person","name":"neutrinoceros"},"datePublished":"2021-04-03T14:32:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/19856/matplotlib/issues/19856"}
| 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:58dfdd5b-1b47-0caa-af95-df167cd9b58a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9464:10F9C5:95F33C:C5E819:6A51A05F |
| html-safe-nonce | b2492b1ea060da15846ff4e76485677a2023142e9320465b5c9dde2eeed5383f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDY0OjEwRjlDNTo5NUYzM0M6QzVFODE5OjZBNTFBMDVGIiwidmlzaXRvcl9pZCI6IjQ2NDI0MTc1NzIwNzA5MjQzODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c3180c75f61ae3fcfce4e032f010c978a54778dd69e2b10ef705d69109e30a4f |
| hovercard-subject-tag | issue:849669494 |
| 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/19856/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5ea2764e51328961076bdcbc23d1b03513a4634a54c87b4f9291203a74910402/matplotlib/matplotlib/issues/19856 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5ea2764e51328961076bdcbc23d1b03513a4634a54c87b4f9291203a74910402/matplotlib/matplotlib/issues/19856 |
| og:image:alt | Bug report Bug summary Contour plots don't interact nicely with matplotlib.colors.LogNorm. Likely related to #19748 Code for reproduction import matplotlib.pyplot as plt from matplotlib.colors impo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | neutrinoceros |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width