Title: [Bug]: Large pixels may overlap when using imshow() · Issue #31009 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Large pixels may overlap when using imshow() · Issue #31009 · matplotlib/matplotlib
X Title: [Bug]: Large pixels may overlap when using imshow() · Issue #31009 · matplotlib/matplotlib
Description: Bug summary When using imshow() with a small array (large pixels), the pixel patches can end up slightly misaligned. This becomes especially obvious when thin grid lines are overlaid on the figure. Code for reproduction import matplotlib...
Open Graph Description: Bug summary When using imshow() with a small array (large pixels), the pixel patches can end up slightly misaligned. This becomes especially obvious when thin grid lines are overlaid on the figure....
X Description: Bug summary When using imshow() with a small array (large pixels), the pixel patches can end up slightly misaligned. This becomes especially obvious when thin grid lines are overlaid on the figure....
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31009
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Large pixels may overlap when using imshow()","articleBody":"### Bug summary\n\nWhen using `imshow()` with a small array (large pixels), the pixel patches can end up slightly misaligned. This becomes especially obvious when thin grid lines are overlaid on the figure.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfig,ax = plt.subplots() \nN = 12 \nax.imshow(np.random.rand(N, N)) \nseps = np.arange(-0.5, N) \nax.vlines(seps, -0.5, N - 0.5, linewidth=1)\nax.hlines(seps, -0.5, N - 0.5, linewidth=1)\nplt.show()\n```\n\n### Actual outcome\n\n\u003cimg width=\"639\" height=\"560\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/a387d152-53c6-4d9b-a75d-fd19f2f54bcd\" /\u003e\n\n### Expected outcome\n\nA figure where none of the pixel patches overlap their respective grid lines.\n\n### Additional information\n\nI originally thought this was the same issue as #14143, see [my original comment](https://github.com/matplotlib/matplotlib/issues/14143#issuecomment-584833923). Eventually that bug was fixed but this issue remained. [To quote @ayshih](https://github.com/matplotlib/matplotlib/issues/14143#issuecomment-3781269196):\n\n\u003e Based on my investigation so far, the problem in your example is indeed distinct from the original issue, and it is very important to fix. It's not a bug internal to the image-resampling code, but rather it has to do with how image placement affects what resampling is requested and how the resampled image is drawn.\n\n### Operating system\n\nDebian\n\n### Matplotlib Version\n\n3.11.0.dev1652+gddd4196c7 (but first found around 3.3.0)\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nuv","author":{"url":"https://github.com/adeak","@type":"Person","name":"adeak"},"datePublished":"2026-01-21T21:55:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/31009/matplotlib/issues/31009"}
| 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:f1f575e4-29fc-021a-2d2d-984cc12c52b6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ECC2:1FF3C2:319BDC:42A22E:6A525C10 |
| html-safe-nonce | 8834abb77a8ae41ae84103661cca0b48495b368bba6be64dd543e2657ffbbce9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0MyOjFGRjNDMjozMTlCREM6NDJBMjJFOjZBNTI1QzEwIiwidmlzaXRvcl9pZCI6IjI2OTY1NDU3NDA1NTQxMzI0OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 014a82690f368afb179c48e77eef25defc9aec9c49a75441a29c0fdb8682229a |
| hovercard-subject-tag | issue:3840194919 |
| 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/31009/issue_layout |
| twitter:image | https://opengraph.githubassets.com/254575b7c95bbac2c0eca8e9668112bb6e8ddc320dd7865ad81040ae42b78e2a/matplotlib/matplotlib/issues/31009 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/254575b7c95bbac2c0eca8e9668112bb6e8ddc320dd7865ad81040ae42b78e2a/matplotlib/matplotlib/issues/31009 |
| og:image:alt | Bug summary When using imshow() with a small array (large pixels), the pixel patches can end up slightly misaligned. This becomes especially obvious when thin grid lines are overlaid on the figure.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adeak |
| 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