Title: `patches.Scatter()` and `patches.Plot()` should be added. · Issue #29318 · matplotlib/matplotlib · GitHub
Open Graph Title: `patches.Scatter()` and `patches.Plot()` should be added. · Issue #29318 · matplotlib/matplotlib
X Title: `patches.Scatter()` and `patches.Plot()` should be added. · Issue #29318 · matplotlib/matplotlib
Description: Problem Only using patches.Rectangle() of plt.subplots() works properly as shown below: from torchvision.datasets import CelebA my_data = CelebA( root="data", split="all", target_type=["bbox", "landmarks"] ) import matplotlib.pyplot as p...
Open Graph Description: Problem Only using patches.Rectangle() of plt.subplots() works properly as shown below: from torchvision.datasets import CelebA my_data = CelebA( root="data", split="all", target_type=["bbox", "lan...
X Description: Problem Only using patches.Rectangle() of plt.subplots() works properly as shown below: from torchvision.datasets import CelebA my_data = CelebA( root="data", split="all", targe...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29318
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`patches.Scatter()` and `patches.Plot()` should be added.","articleBody":"### Problem\r\n\r\nOnly using [patches.Rectangle()](https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Rectangle.html) of [plt.subplots()](https://matplotlib.org/stable/gallery/subplots_axes_and_figures/subplots_demo.html#creating-multiple-subplots-using-plt-subplots) works properly as shown below:\r\n\r\n```python\r\nfrom torchvision.datasets import CelebA\r\n\r\nmy_data = CelebA(\r\n root=\"data\",\r\n split=\"all\",\r\n target_type=[\"bbox\", \"landmarks\"]\r\n)\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.patches import Rectangle\r\n\r\nfig, axes = plt.subplots(nrows=2, ncols=5, figsize=(12, 6))\r\nfor (im, ((x, y, w, h), lm)), axis in zip(my_data, axes.ravel()):\r\n axis.imshow(X=im)\r\n rect = Rectangle(xy=(x, y), width=w, height=h, linewidth=3, edgecolor='r', facecolor='none', clip_on=True) # Here\r\n axis.add_patch(p=rect) # Here\r\n```\r\n\r\n\r\n\r\nAnd only using [axes.Axes.scatter()](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.scatter.html) of `plt.subplots()` works properly as shown below:\r\n\r\n```python\r\nfrom torchvision.datasets import CelebA\r\nimport torchvision\r\n\r\nmy_data = CelebA(\r\n root=\"data\",\r\n split=\"all\",\r\n target_type=[\"bbox\", \"landmarks\"]\r\n)\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.patches import Rectangle\r\nfrom matplotlib.patches import Circle\r\n\r\nfig, axes = plt.subplots(nrows=2, ncols=5, figsize=(12, 6))\r\nfor (im, ((x, y, w, h), lm)), axis in zip(my_data, axes.ravel()):\r\n axis.imshow(X=im)\r\n\r\n for px, py in lm.split(2): # Here\r\n axis.scatter(x=px, y=py, c='#1f77b4') # Here\r\n```\r\n\r\n\r\n\r\nAnd only using `axes.Axes.plot()` of `plt.subplots()` works properly as shown below:\r\n\r\n```python\r\nfrom torchvision.datasets import CelebA\r\nimport torchvision\r\n\r\nmy_data = CelebA(\r\n root=\"data\",\r\n split=\"all\",\r\n target_type=[\"bbox\", \"landmarks\"]\r\n)\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.patches import Rectangle\r\nfrom matplotlib.patches import Circle\r\n\r\nfig, axes = plt.subplots(nrows=2, ncols=5, figsize=(12, 6))\r\nfor (im, ((x, y, w, h), lm)), axis in zip(my_data, axes.ravel()):\r\n axis.imshow(X=im)\r\n\r\n px = [] # Here\r\n py = [] # Here\r\n for j, v in enumerate(lm): # Here\r\n if j%2 == 0: # Here\r\n px.append(v) # Here\r\n else: # Here\r\n py.append(v) # Here\r\n axis.plot(px, py) # Here\r\n```\r\n\r\n\r\n\r\nBut using `patches.Rectangle()` of `plt.subplots()` with `axes.Axes.scatter()` of `plt.subplots()` doesn't work properly as shown below:\r\n\r\n```python\r\nfrom torchvision.datasets import CelebA\r\n\r\nmy_data = CelebA(\r\n root=\"data\",\r\n split=\"all\",\r\n target_type=[\"bbox\", \"landmarks\"]\r\n)\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.patches import Rectangle\r\n\r\nfig, axes = plt.subplots(nrows=2, ncols=5, figsize=(12, 6))\r\nfor (im, ((x, y, w, h), lm)), axis in zip(my_data, axes.ravel()):\r\n axis.imshow(X=im)\r\n rect = Rectangle(xy=(x, y), width=w, height=h, linewidth=3, edgecolor='r', facecolor='none', clip_on=True) # Here\r\n axis.add_patch(p=rect) # Here\r\n\r\n for px, py in lm.split(2): # Here\r\n axis.scatter(x=px, y=py, c='#1f77b4') # Here\r\n```\r\n\r\n\r\n\r\nAnd using `patches.Rectangle()` of `plt.subplots()` with `axes.Axes.plot()` of `plt.subplots()` doesn't work properly as shown below:\r\n\r\n```python\r\nfrom torchvision.datasets import CelebA\r\n\r\nmy_data = CelebA(\r\n root=\"data\",\r\n split=\"all\",\r\n target_type=[\"bbox\", \"landmarks\"]\r\n)\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.patches import Rectangle\r\n\r\nfig, axes = plt.subplots(nrows=2, ncols=5, figsize=(12, 6))\r\nfor (im, ((x, y, w, h), lm)), axis in zip(my_data, axes.ravel()):\r\n axis.imshow(X=im)\r\n rect = Rectangle(xy=(x, y), width=w, height=h, linewidth=3, edgecolor='r', facecolor='none', clip_on=True) # Here\r\n axis.add_patch(p=rect) # Here\r\n\r\n px = [] # Here\r\n py = [] # Here\r\n for j, v in enumerate(lm): # Here\r\n if j%2 == 0: # Here\r\n px.append(v) # Here\r\n else: # Here\r\n py.append(v) # Here\r\n axis.plot(px, py) # Here\r\n```\r\n\r\n\r\n\r\nSo instead, I used `patches.Rectangle()` of `plt.subplots()` with [patches.Circle()](https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Circle.html) of `plt.subplots()`, then they properly work as shown below:\r\n\r\n```python\r\nfrom torchvision.datasets import CelebA\r\n\r\nmy_data = CelebA(\r\n root=\"data\",\r\n split=\"all\",\r\n target_type=[\"bbox\", \"landmarks\"]\r\n)\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.patches import Rectangle\r\nfrom matplotlib.patches import Circle\r\n\r\nfig, axes = plt.subplots(nrows=2, ncols=5, figsize=(12, 6))\r\nfor (im, ((x, y, w, h), lm)), axis in zip(my_data, axes.ravel()):\r\n axis.imshow(X=im)\r\n rect = Rectangle(xy=(x, y), width=w, height=h, linewidth=3, edgecolor='r', facecolor='none', clip_on=True) # Here\r\n axis.add_patch(p=rect) # Here\r\n\r\n for px, py in lm.split(2): # Here\r\n axis.add_patch(p=Circle(xy=(px, py))) # Here\r\n```\r\n\r\n\r\n\r\n### Proposed solution\r\n\r\nSo, it seems like [matplotlib.patches](https://matplotlib.org/stable/api/patches_api.html) works with `matplotlib.patches` so `patches.Scatter()` and `patches.Plot()` should be added.","author":{"url":"https://github.com/hyperkai","@type":"Person","name":"hyperkai"},"datePublished":"2024-12-15T17:14:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/29318/matplotlib/issues/29318"}
| 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:291bdde8-f6aa-0adc-41b5-48d9422557d8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD44:2521B5:E2B0B6:134A6B0:6A521C8D |
| html-safe-nonce | f2162cd23840f3f9c38f3328ecfb4bb48fcf07c23112dbd098afdb18b772eab3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDQ0OjI1MjFCNTpFMkIwQjY6MTM0QTZCMDo2QTUyMUM4RCIsInZpc2l0b3JfaWQiOiI1NjY5OTU1Mjg4OTUxODIzNTAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2182f60e6360c8257ade5b66115e49ee8838bba325030741456cc850ba68bdb4 |
| hovercard-subject-tag | issue:2740771736 |
| 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/29318/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7ab417150f46a7c209359db90f09d4f701948b858ccc35c3f370c6815af4001d/matplotlib/matplotlib/issues/29318 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7ab417150f46a7c209359db90f09d4f701948b858ccc35c3f370c6815af4001d/matplotlib/matplotlib/issues/29318 |
| og:image:alt | Problem Only using patches.Rectangle() of plt.subplots() works properly as shown below: from torchvision.datasets import CelebA my_data = CelebA( root="data", split="all", target_type=["bbox", "lan... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hyperkai |
| 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