Title: [Bug]: Irregular pixel widths in rasterized pcolor · Issue #23391 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Irregular pixel widths in rasterized pcolor · Issue #23391 · matplotlib/matplotlib
X Title: [Bug]: Irregular pixel widths in rasterized pcolor · Issue #23391 · matplotlib/matplotlib
Description: Bug summary Pixel widths appear irregularly in pcolor(x, y, z, rasterized=True), while x and y are regular. Using rasterized=False provides correct (equal size) pixels, but saving the figure to .png (instead of .pdf) will show the same i...
Open Graph Description: Bug summary Pixel widths appear irregularly in pcolor(x, y, z, rasterized=True), while x and y are regular. Using rasterized=False provides correct (equal size) pixels, but saving the figure to .pn...
X Description: Bug summary Pixel widths appear irregularly in pcolor(x, y, z, rasterized=True), while x and y are regular. Using rasterized=False provides correct (equal size) pixels, but saving the figure to .pn...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/23391
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Irregular pixel widths in rasterized pcolor","articleBody":"### Bug summary\n\nPixel widths appear irregularly in `pcolor(x, y, z, rasterized=True)`, while `x` and `y` are regular. Using `rasterized=False` provides correct (equal size) pixels, but saving the figure to `.png` (instead of `.pdf`) will show the same irregular pixel width bug.\r\n\r\nIt looks like a resampling bug, which messes up precise data visualization completely.\n\n### Code for reproduction\n\n```python\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nx, y = np.meshgrid(range(500), range(2))\r\nz = [np.tile([0,1],250), np.tile([0,1],250)]\r\nfig, ax = plt.subplots(1,1, figsize=(10,2))\r\nim = ax.pcolor(x, y, z, rasterized=True)\r\nax.set_xticks(np.arange(0,40))\r\nfig.savefig('test.pdf')\r\nplt.show()\n```\n\n\n### Actual outcome\n\nIn the resulting plot, some pixels are thinner, and some are thicker, than they should be. \r\n`rasterize=True` (zoom-in to the lower left corner)\r\n\r\n\n\n### Expected outcome\n\n`rasterize=False` (zoom-in to the lower left corner)\r\n\r\n\n\n### Additional information\n\n- This behaviour depends on the number of pixels plotted, for me it becomes visible above `len(x)\u003e100`.\r\n- The spread between thicker and thinner lines increases with increasing size of the input array.\r\n- If the view is reduced to a lower number of pixels (e.g., `ax.set_xlim(0,10)`), the effect is no longer visible.\n\n### Operating system\n\nWindows\n\n### Matplotlib Version\n\n3.5.1\n\n### Matplotlib Backend\n\ninline\n\n### Python version\n\n3.9.6\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/mschroen","@type":"Person","name":"mschroen"},"datePublished":"2022-07-06T12:22:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/23391/matplotlib/issues/23391"}
| 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:9e87e4e6-0525-12e2-11de-87140cedcb93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1EC:3B799C:2B7EA4:2C1995:6A514019 |
| html-safe-nonce | e6aa71248f3057897049fcffe078c34ed2711ea3be854e895219a70074344e9e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUVDOjNCNzk5QzoyQjdFQTQ6MkMxOTk1OjZBNTE0MDE5IiwidmlzaXRvcl9pZCI6Ijg4ODg3NDEzNDgzNzY2NTc5NDUiLCJyZWdpb25fZWRnZSI6InNlYSIsInJlZ2lvbl9yZW5kZXIiOiJzZWEifQ== |
| visitor-hmac | ec47bf2746ca403befa88a9cb0db51d9fc275cbdf25dd1667721a6ff4fbdd341 |
| hovercard-subject-tag | issue:1295759925 |
| 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/23391/issue_layout |
| twitter:image | https://opengraph.githubassets.com/870032026b21373e6d81a04ab481296afa2d5b4658c09f84a9da80607e3d39aa/matplotlib/matplotlib/issues/23391 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/870032026b21373e6d81a04ab481296afa2d5b4658c09f84a9da80607e3d39aa/matplotlib/matplotlib/issues/23391 |
| og:image:alt | Bug summary Pixel widths appear irregularly in pcolor(x, y, z, rasterized=True), while x and y are regular. Using rasterized=False provides correct (equal size) pixels, but saving the figure to .pn... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mschroen |
| hostname | github.com |
| expected-hostname | github.com |
| None | e840f405b2718e8f2d55aafa9ff27dbce17e29d0c253011d05ea0fea3c78baff |
| 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 | e876f00c5723f6080b9d294e4958fd4d506e6faf |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width