Title: [Bug]: Enforce that Line data modifications are sequences · Issue #28927 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Enforce that Line data modifications are sequences · Issue #28927 · matplotlib/matplotlib
X Title: [Bug]: Enforce that Line data modifications are sequences · Issue #28927 · matplotlib/matplotlib
Description: Bug summary It used to be possible to use Line2D.set_ydata with a single scalar. From a quick search I think this behaviour was changed in #22329, and I guess it makes sense for a lot of cases. However, I don't think mandating a sequence...
Open Graph Description: Bug summary It used to be possible to use Line2D.set_ydata with a single scalar. From a quick search I think this behaviour was changed in #22329, and I guess it makes sense for a lot of cases. How...
X Description: Bug summary It used to be possible to use Line2D.set_ydata with a single scalar. From a quick search I think this behaviour was changed in #22329, and I guess it makes sense for a lot of cases. How...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28927
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Enforce that Line data modifications are sequences","articleBody":"### Bug summary\n\nIt used to be possible to use `Line2D.set_ydata` with a single scalar. From a quick search I think this behaviour was changed in #22329, and I guess it makes sense for a lot of cases. However, I don't think mandating a sequence really makes sense when `Line2D` was created by `ax.axhline`, or `ax.axvline`, because those two methods use scalars themselves, not sequences.\n\n### Code for reproduction\n\n```Python\nfig, ax = plt.subplots()\r\nl = ax.axvline(x=10)\r\nl.set_xdata(15)\n```\n\n\n### Actual outcome\n\n```\r\n---------------------------------------------------------------------------\r\nRuntimeError Traceback (most recent call last)\r\nCell In[8], line 4\r\n 2 fig, ax = plt.subplots()\r\n 3 l = ax.axvline(x=10)\r\n----\u003e 4 l.set_xdata(15)\r\n\r\nFile [~/miniforge3/envs/dev3/lib/python3.12/site-packages/matplotlib/lines.py:1289](http://localhost:8888/lab/tree/data/reduce/~/miniforge3/envs/dev3/lib/python3.12/site-packages/matplotlib/lines.py#line=1288), in Line2D.set_xdata(self, x)\r\n 1276 \"\"\"\r\n 1277 Set the data array for x.\r\n 1278 \r\n (...)\r\n 1286 set_ydata\r\n 1287 \"\"\"\r\n 1288 if not np.iterable(x):\r\n-\u003e 1289 raise RuntimeError('x must be a sequence')\r\n 1290 self._xorig = copy.copy(x)\r\n 1291 self._invalidx = True\r\n\r\nRuntimeError: x must be a sequence\r\n```\n\n### Expected outcome\n\nA plot with horizontal/vertical line\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.9.2\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/andyfaff","@type":"Person","name":"andyfaff"},"datePublished":"2024-10-03T04:52:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/28927/matplotlib/issues/28927"}
| 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:5b987a9a-cc46-4fb5-8548-ad551f5f288c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BC4:339DB6:A355E4:E27D10:6A5133AB |
| html-safe-nonce | 6c58c24cd69b5e21dbae5dfa07b18763be17ba087996d99ea94d8ee77541c1f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkM0OjMzOURCNjpBMzU1RTQ6RTI3RDEwOjZBNTEzM0FCIiwidmlzaXRvcl9pZCI6IjYzOTY3NDc0NDE3NDYyMTYxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b7d1b76580e490bd908bb65c2bc15b320c99196226af8b1bd3e24b3ae3ea123c |
| hovercard-subject-tag | issue:2563120276 |
| 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/28927/issue_layout |
| twitter:image | https://opengraph.githubassets.com/770256b113d8b061fecc7c146e926e41794aa4540f2c67ce829f5554d5c017d3/matplotlib/matplotlib/issues/28927 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/770256b113d8b061fecc7c146e926e41794aa4540f2c67ce829f5554d5c017d3/matplotlib/matplotlib/issues/28927 |
| og:image:alt | Bug summary It used to be possible to use Line2D.set_ydata with a single scalar. From a quick search I think this behaviour was changed in #22329, and I guess it makes sense for a lot of cases. How... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andyfaff |
| 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 | 4ae6027e8ba70c79dc08249bb6cdc1a09d788496 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width