Title: [Bug]: Plotting numpy.array of dtype float32 with pyplot.imshow and specified colors.LogNorm produces wrong colors · Issue #28731 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Plotting numpy.array of dtype float32 with pyplot.imshow and specified colors.LogNorm produces wrong colors · Issue #28731 · matplotlib/matplotlib
X Title: [Bug]: Plotting numpy.array of dtype float32 with pyplot.imshow and specified colors.LogNorm produces wrong colors · Issue #28731 · matplotlib/matplotlib
Description: Bug summary Plotting an equal numpy.array of dtype float64 and float32 with pyplot.imshow and a defined colors.LogNorm as norm will produce different colors in the resulting image. Code for reproduction import matplotlib.pyplot as plt im...
Open Graph Description: Bug summary Plotting an equal numpy.array of dtype float64 and float32 with pyplot.imshow and a defined colors.LogNorm as norm will produce different colors in the resulting image. Code for reprodu...
X Description: Bug summary Plotting an equal numpy.array of dtype float64 and float32 with pyplot.imshow and a defined colors.LogNorm as norm will produce different colors in the resulting image. Code for reprodu...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28731
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Plotting numpy.array of dtype float32 with pyplot.imshow and specified colors.LogNorm produces wrong colors","articleBody":"### Bug summary\n\nPlotting an equal numpy.array of dtype float64 and float32 with pyplot.imshow and a defined colors.LogNorm as norm will produce different colors in the resulting image.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\r\nimport matplotlib.colors as colors\r\nimport numpy as np\r\n\r\nnorm = colors.LogNorm(vmin=1e-10, vmax=1)\r\ntest_numpy = np.array([[1e-4]])\r\ntest_numpy_32 = np.array([[1e-4]], dtype=np.float32)\r\n\r\nfor test in [test_numpy, test_numpy_32]:\r\n plt.imshow(test, norm=norm)\r\n plt.title(f\"numpy array of dtype: {test.dtype}\")\r\n plt.colorbar()\r\n plt.show()\n```\n\n\n### Actual outcome\n\nThe resulting plot for the dtype float64 numpy.array looks like this:\r\n\r\n\r\n\r\nand the plot for the dtype float32 numpy.array looks like this:\r\n\r\n\n\n### Expected outcome\n\nI would expect both outputs to have the same color.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nArch\n\n### Matplotlib Version\n\n3.9.1.post1\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\nPython 3.12.4\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/faressc","@type":"Person","name":"faressc"},"datePublished":"2024-08-15T16:59:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/28731/matplotlib/issues/28731"}
| 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:e87eaa99-1dc4-9149-513a-cd905c9437c2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD1E:1BF8C0:3BA59D:4FBFB0:6A52924C |
| html-safe-nonce | 8254ad9f6c282c3302fba2ab23071e680e6e876c43ca6724d0554184be62aebf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDFFOjFCRjhDMDozQkE1OUQ6NEZCRkIwOjZBNTI5MjRDIiwidmlzaXRvcl9pZCI6IjgyNDM0MDQ5ODQzOTEyMDk1NDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b0bac0455daa83b8ea864ce217deaaafcd299929d1e11aba49af466554e44c8c |
| hovercard-subject-tag | issue:2468490112 |
| 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/28731/issue_layout |
| twitter:image | https://opengraph.githubassets.com/925a7c8cb5b92a95c239ca2bc9105d999e2a9ad0d4d0fcad921232104047ec15/matplotlib/matplotlib/issues/28731 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/925a7c8cb5b92a95c239ca2bc9105d999e2a9ad0d4d0fcad921232104047ec15/matplotlib/matplotlib/issues/28731 |
| og:image:alt | Bug summary Plotting an equal numpy.array of dtype float64 and float32 with pyplot.imshow and a defined colors.LogNorm as norm will produce different colors in the resulting image. Code for reprodu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | faressc |
| 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