Title: Doubling of coordinates in polygon clipping · Issue #5670 · matplotlib/matplotlib · GitHub
Open Graph Title: Doubling of coordinates in polygon clipping · Issue #5670 · matplotlib/matplotlib
X Title: Doubling of coordinates in polygon clipping · Issue #5670 · matplotlib/matplotlib
Description: The following code snippet takes coordinates for a hand, and clips it to a rectangular window. Of the returned polygon, the endpoints are duplicated. from matplotlib import path, transforms import matplotlib.pyplot as plt import numpy as...
Open Graph Description: The following code snippet takes coordinates for a hand, and clips it to a rectangular window. Of the returned polygon, the endpoints are duplicated. from matplotlib import path, transforms import ...
X Description: The following code snippet takes coordinates for a hand, and clips it to a rectangular window. Of the returned polygon, the endpoints are duplicated. from matplotlib import path, transforms import ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/5670
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Doubling of coordinates in polygon clipping","articleBody":"The following code snippet takes coordinates for a hand, and clips it to a rectangular window. Of the returned polygon, the endpoints are duplicated.\n\n```\nfrom matplotlib import path, transforms\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nhand = np.array(\n [[ 1.64516129, 1.16145833 ],\n [ 1.64516129, 1.59375 ],\n [ 1.35080645, 1.921875 ],\n [ 1.375 , 2.18229167 ],\n [ 1.68548387, 1.9375 ],\n [ 1.60887097, 2.55208333 ],\n [ 1.68548387, 2.69791667 ],\n [ 1.76209677, 2.56770833 ],\n [ 1.83064516, 1.97395833 ],\n [ 1.89516129, 2.75 ],\n [ 1.9516129 , 2.84895833 ],\n [ 2.01209677, 2.76041667 ],\n [ 1.99193548, 1.99479167 ],\n [ 2.11290323, 2.63020833 ],\n [ 2.2016129 , 2.734375 ],\n [ 2.25403226, 2.60416667 ],\n [ 2.14919355, 1.953125 ],\n [ 2.30645161, 2.36979167 ],\n [ 2.39112903, 2.36979167 ],\n [ 2.41532258, 2.1875 ],\n [ 2.1733871 , 1.703125 ],\n [ 2.07782258, 1.16666667 ]])\n\n(r0, c0, r1, c1) = (1.0, 1.5, 2.1, 2.5)\n\npoly = path.Path(np.vstack((hand[:, 1], hand[:, 0])).T, closed=True)\nclip_rect = transforms.Bbox([[r0, c0], [r1, c1]])\npoly_clipped = poly.clip_to_bbox(clip_rect).to_polygons()[0]\n\nprint(len(poly_clipped[:, 0]), len(poly_clipped[:, 1]))\n\nplt.plot(hand[:, 0], hand[:, 1], 'r-')\nplt.plot(poly_clipped[:, 1], poly_clipped[:, 0], 'go-')\nplt.show()\n\nprint(poly_clipped[-2:, :])\n```\n","author":{"url":"https://github.com/stefanv","@type":"Person","name":"stefanv"},"datePublished":"2015-12-14T09:08:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/5670/matplotlib/issues/5670"}
| 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:5772bdd7-8f6d-366a-d21b-611cef8091c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 869E:1C3DD7:197D8E1:2203448:6A52C49D |
| html-safe-nonce | d2e2d2d655c0f60d92c69d375cbd132b40d69c9ab6653e31d8b23466999cdf24 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjlFOjFDM0RENzoxOTdEOEUxOjIyMDM0NDg6NkE1MkM0OUQiLCJ2aXNpdG9yX2lkIjoiMTMzODU3MzkyNDQ4MTU0OTQ2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9649c07fca41371a5368be92d4fccb3deed8834bfafc9919064c9a2f76c92c9b |
| hovercard-subject-tag | issue:122001269 |
| 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/5670/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b28d530ecbcef42b633f02ee7b8465ec53b2dea00d050909d1a9f2c70c1e7b7b/matplotlib/matplotlib/issues/5670 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b28d530ecbcef42b633f02ee7b8465ec53b2dea00d050909d1a9f2c70c1e7b7b/matplotlib/matplotlib/issues/5670 |
| og:image:alt | The following code snippet takes coordinates for a hand, and clips it to a rectangular window. Of the returned polygon, the endpoints are duplicated. from matplotlib import path, transforms import ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | stefanv |
| 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