Title: Fixed lingering bugs with image rendering related to exact half display pixels by ayshih · Pull Request #31313 · matplotlib/matplotlib · GitHub
Open Graph Title: Fixed lingering bugs with image rendering related to exact half display pixels by ayshih · Pull Request #31313 · matplotlib/matplotlib
X Title: Fixed lingering bugs with image rendering related to exact half display pixels by ayshih · Pull Request #31313 · matplotlib/matplotlib
Description: PR summary This is a follow-on to #31021 to fix image-rendering bugs when a display pixel is exactly aligned with the edge between two image pixels (or with the edge of the image). An attempt at a fix was part of #31021, but the tests there had not been carefully crafted to verify that the bugs were comprehensively fixed. Before this PR After this PR Generating code import matplotlib.pyplot as plt import numpy as np from matplotlib.transforms import Transform # Create a nonaffine identity to easily convert an affine transform to its nonaffine equivalent class NonAffineIdentityTransform(Transform): input_dims = 2 output_dims = 2 def inverted(self): return self nonaffine_identity = NonAffineIdentityTransform() fig = plt.figure(figsize=(10, 5)) fig.set_facecolor('g') # All values in this test are chosen carefully so that many display pixels are # aligned with an edge or a corner of an input pixel # Layout: # Top row is origin='upper', bottom row is origin='lower' # Column 1: affine transform, anchored at whole pixel # Column 2: affine transform, anchored at half pixel # Column 3: nonaffine transform, anchored at whole pixel # Column 4: nonaffine transform, anchored at half pixel # Column 5: affine transform, anchored at half pixel, interpolation='hanning' # Each axes patch is magenta, so seeing a magenta line at an edge of the image # means that the image is not filling the axes corner_x = [0.01, 0.199, 0.41, 0.599, 0.81] corner_y = [0.1, 0.5] axs = [] for cy in corner_y: for ix, cx in enumerate(corner_x): mx = cx + 0.0005 if ix in [1, 3, 4] else cx my = cy + 0.011 if ix in [1, 3, 4] else cy axs.append(fig.add_axes([mx, my, 0.175, 0.35], xticks=[], yticks=[])) N = 10 data = np.arange(N**2).reshape((N, N)) % 9 seps = np.arange(-0.5, N) for i, ax in enumerate(axs): ax.set_facecolor('m') ax.imshow(data, cmap='Blues', interpolation='hanning' if i % 5 == 4 else 'nearest', origin='upper' if i >= 5 else 'lower', transform=nonaffine_identity + ax.transData if i % 4 >= 2 else ax.transData) ax.vlines(seps, -0.5, N - 0.5, linewidth=0.5, color='red', linestyle=(0, (3, 6))) ax.hlines(seps, -0.5, N - 0.5, linewidth=0.5, color='red', linestyle=(0, (3, 6))) for spine in ax.spines: ax.spines[spine].set_linestyle((0, (5, 10))) plt.show() AI Disclosure N/A PR checklist [N/A] "closes #0000" is in the body of the PR description to link the related issue new and changed code is tested [N/A] Plotting related features are demonstrated in an example [N/A] New Features and API Changes are noted with a directive and release note [N/A] Documentation complies with general and docstring guidelines
Open Graph Description: PR summary This is a follow-on to #31021 to fix image-rendering bugs when a display pixel is exactly aligned with the edge between two image pixels (or with the edge of the image). An attempt at ...
X Description: PR summary This is a follow-on to #31021 to fix image-rendering bugs when a display pixel is exactly aligned with the edge between two image pixels (or with the edge of the image). An attempt at ...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/31313
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8503cee9-8c3c-a71e-c659-6757ca829d89 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AC88:3F1247:15824F9:1D63F52:6A53E239 |
| html-safe-nonce | a666f83e8f550edd59c0cfcf48a1ebef09a7874af224beed19143efc51fabc74 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzg4OjNGMTI0NzoxNTgyNEY5OjFENjNGNTI6NkE1M0UyMzkiLCJ2aXNpdG9yX2lkIjoiMzE5MDY1NzU3MzA2Mjk1OTY3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c59d3b84a8ff3404aaf6d888d46e2e5478ed309f1e5053c2e1c8916ad8e64915 |
| hovercard-subject-tag | pull_request:3402607902 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/matplotlib/matplotlib/pull/31313/files |
| twitter:image | https://avatars.githubusercontent.com/u/991759?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/991759?s=400&v=4 |
| og:image:alt | PR summary This is a follow-on to #31021 to fix image-rendering bugs when a display pixel is exactly aligned with the edge between two image pixels (or with the edge of the image). An attempt at ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| 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