Title: Incorrect & inconsistent coloring in .imshow() with LogNorm · Issue #19748 · matplotlib/matplotlib · GitHub
Open Graph Title: Incorrect & inconsistent coloring in .imshow() with LogNorm · Issue #19748 · matplotlib/matplotlib
X Title: Incorrect & inconsistent coloring in .imshow() with LogNorm · Issue #19748 · matplotlib/matplotlib
Description: Bug report Bug summary .imshow() with LogNorm produces incorrect and inconsistent coloring. Code for reproduction In this example the same array was plotted twice. The first .imshow() call plots the whole array. The following two plot tw...
Open Graph Description: Bug report Bug summary .imshow() with LogNorm produces incorrect and inconsistent coloring. Code for reproduction In this example the same array was plotted twice. The first .imshow() call plots th...
X Description: Bug report Bug summary .imshow() with LogNorm produces incorrect and inconsistent coloring. Code for reproduction In this example the same array was plotted twice. The first .imshow() call plots th...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19748
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect \u0026 inconsistent coloring in .imshow() with LogNorm","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\n.imshow() with LogNorm produces incorrect and inconsistent coloring. \r\n\r\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\n**Code for reproduction**\r\n\r\nIn this example the same array was plotted twice. The first .imshow() call plots the whole array. The following two plot two halves of the same array separately. \r\n\r\nThe `mpl_toolkits` is used only to fix axes and colorbar positioning; problems with coloring remain even without it.\r\n\r\n```python\r\nimport matplotlib as mpl\r\nimport matplotlib.pyplot as plt\r\nfrom mpl_toolkits.axes_grid1 import make_axes_locatable\r\n\r\nimport numpy as np\r\n\r\na = 10. ** np.arange(100)\r\n\r\nfig, ax = plt.subplots(1)\r\nnorm = mpl.colors.LogNorm(np.min(a), np.max(a))\r\n\r\nimg1 = ax.imshow(a[None, : ], extent = (0, 100, 0, 10),\r\n cmap = 'gray', norm = norm )\r\nimg2 = ax.imshow(a[None, :50], extent = (0, 50, -10, 0),\r\n cmap = 'gray', norm = norm )\r\nimg3 = ax.imshow(a[None, 50: ], extent = (50, 100, -10, 0),\r\n cmap = 'gray', norm = norm )\r\n\r\nplt.xlim( 0, 100)\r\nplt.ylim(-10, 10)\r\n\r\ndivider = make_axes_locatable(plt.gca())\r\ncax = divider.append_axes(\"bottom\",\r\n size=0.2,\r\n pad=0.4 )\r\nplt.colorbar(img1, cax = cax, orientation='horizontal')\r\n\r\nplt.tight_layout()\r\n\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\nAs we can see, left parts of each patch produced by .imshow() is completely black. It seems like rounding occurred somewhere. It also can be seen, that different colors are used to represent the same numbers in different arrays.\r\n\r\n\r\n\r\n\r\n**Expected outcome**\r\n\r\nIt was expected to see smooth transition from black to white from left to right. It was also expected not to see any difference in colors representing same numbers.\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: Linux\r\n * Matplotlib version (`import matplotlib; print(matplotlib.__version__)`): 3.3.3\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): Qt5Agg\r\n * Python version: 3.7.3\r\n\r\nThe matplotlib package was installed with pip.\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/mdmisch","@type":"Person","name":"mdmisch"},"datePublished":"2021-03-20T11:32:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":18},"url":"https://github.com/19748/matplotlib/issues/19748"}
| 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:10478bb6-adc5-3ba0-dcc1-ca4cb9f65840 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A1FC:30769A:3BB52A:4FB4EB:6A529142 |
| html-safe-nonce | 74a10cff2c6702d747a99d9f1efbebd48ebdb4bb5230dcb2ff552d747c42e95c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUZDOjMwNzY5QTozQkI1MkE6NEZCNEVCOjZBNTI5MTQyIiwidmlzaXRvcl9pZCI6IjEzNTYzMzI3MzgwNzcxNjc5MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 18d570acc4d501d6f8ed6bfec0f413ab96f5b35a4f26bba133a8fce079aaea16 |
| hovercard-subject-tag | issue:836785949 |
| 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/19748/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de3a8256146ea0c3537d250b65376e944811800930cdb0ff73fd230932606ff4/matplotlib/matplotlib/issues/19748 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de3a8256146ea0c3537d250b65376e944811800930cdb0ff73fd230932606ff4/matplotlib/matplotlib/issues/19748 |
| og:image:alt | Bug report Bug summary .imshow() with LogNorm produces incorrect and inconsistent coloring. Code for reproduction In this example the same array was plotted twice. The first .imshow() call plots th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mdmisch |
| 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