Title: Line2D can snap incorrectly and request snap(x)(y) parameters · Issue #19054 · matplotlib/matplotlib · GitHub
Open Graph Title: Line2D can snap incorrectly and request snap(x)(y) parameters · Issue #19054 · matplotlib/matplotlib
X Title: Line2D can snap incorrectly and request snap(x)(y) parameters · Issue #19054 · matplotlib/matplotlib
Description: Bug report Bug summary Axes.plot produces thin lines (1, 3, ... px) which may snap incorrectly relative to Rectangles depending on the dpi and Axes position, in other words, the width of the left and bottom margins. In such cases, non-sn...
Open Graph Description: Bug report Bug summary Axes.plot produces thin lines (1, 3, ... px) which may snap incorrectly relative to Rectangles depending on the dpi and Axes position, in other words, the width of the left a...
X Description: Bug report Bug summary Axes.plot produces thin lines (1, 3, ... px) which may snap incorrectly relative to Rectangles depending on the dpi and Axes position, in other words, the width of the left a...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19054
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Line2D can snap incorrectly and request snap(x)(y) parameters","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\n\r\n`Axes.plot` produces thin lines (1, 3, ... px) which may snap incorrectly relative to `Rectangle`s depending on the `dpi` and `Axes` position, in other words, the width of the left and bottom margins. In such cases, non-snapped lines achieve the desired outcome.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nfrom matplotlib.pyplot import figure\r\nfrom matplotlib.patches import Rectangle\r\n\r\nfig = figure(figsize=(10,10), dpi=155)\r\nax = fig.add_axes([0.09, 0.1, 0.8, 0.86])\r\nax.axis([0, 1240, 0, 1333])\r\nax.minorticks_on()\r\nax.grid(which='both', ls=':')\r\n\r\nax.add_patch(Rectangle((700,800), 200, 3, snap=True))\r\nax.add_patch(Rectangle((800,700), 3, 200, snap=True))\r\nlw = 1 * 72 / 155\r\nax.plot([890,801.5,801.5], [801.5,801.5,890], c='lime', lw=lw, snap=True)\r\nax.plot([710,801.5,801.5], [801.5,801.5,710], c='red', lw=lw, snap=False)\r\n\r\nfig.savefig(\"snap.png\")\r\n```\r\n\r\nThe `Axes` relative position of (0.09, 0.1) is chosen on purpose so that the left margin is 0.09 * 10 in * 155 dpi = 139.5 px and the bottom one is 155 px. Also note that the `Axis` are scaled to be 1 pixel : 1 unit.\r\n\r\n**Actual outcome**\r\n\r\nZoom in to view individual pixels...\r\n\r\n\r\n\r\n**Expected outcome**\r\n\r\nThat the lime line snaps correctly in the middle of the blue `Rectangle`s. Note how the horizontal non-snapped red line works as desired.\r\n\r\n**Feature request**\r\n\r\nTo implement something equivalent to `snapx` and `snapy` following `scalex` and `scaley` trend. #15595 might change this trend though. This feature could be used to work around this issue, but I think the solutions should be independent. Will split this request into another issue if it's welcomed.\r\n\r\n**Matplotlib version**\r\n\r\n * Operating system: Windows 10\r\n * Matplotlib version: 3.3.3\r\n * Matplotlib backend: module://ipykernel.pylab.backend_inline\r\n * Python version: 3.9.0\r\n\r\nPython installed via official installer. Matplotlib installed via pip.","author":{"url":"https://github.com/alexiscoutinho","@type":"Person","name":"alexiscoutinho"},"datePublished":"2020-12-01T18:14:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/19054/matplotlib/issues/19054"}
| 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:4e97a5ec-9963-643b-640d-d58d6ee71064 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AADE:2804AF:A0628:DCBFD:6A52364A |
| html-safe-nonce | 4a0879feb669035ae3370a31f00de9b7550b929b633a8c83701c2fe7ed8d9462 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQURFOjI4MDRBRjpBMDYyODpEQ0JGRDo2QTUyMzY0QSIsInZpc2l0b3JfaWQiOiI1Njc1NjEyNzE0MzYzNDAxODAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0984f97af663ab7256258bdffcbd9ae4a10161176206f6c4b5ec0b7e1391ff97 |
| hovercard-subject-tag | issue:754616577 |
| 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/19054/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b3ecbf7339ecbe8336425e53f85092f909f8c92922f9baed607350b3ff02b356/matplotlib/matplotlib/issues/19054 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b3ecbf7339ecbe8336425e53f85092f909f8c92922f9baed607350b3ff02b356/matplotlib/matplotlib/issues/19054 |
| og:image:alt | Bug report Bug summary Axes.plot produces thin lines (1, 3, ... px) which may snap incorrectly relative to Rectangles depending on the dpi and Axes position, in other words, the width of the left a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexiscoutinho |
| 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