Title: Passing an incorrectly sized colour list to scatter should raise a relevant error · Issue #9209 · matplotlib/matplotlib · GitHub
Open Graph Title: Passing an incorrectly sized colour list to scatter should raise a relevant error · Issue #9209 · matplotlib/matplotlib
X Title: Passing an incorrectly sized colour list to scatter should raise a relevant error · Issue #9209 · matplotlib/matplotlib
Description: If the length of the c argument to matplotlib.pyplot.scatter doesn't match the size of the x and y arguments, a confusing error message is raised: Invalid RGBA argument. Contrast this with the error that results if x and y are not the sa...
Open Graph Description: If the length of the c argument to matplotlib.pyplot.scatter doesn't match the size of the x and y arguments, a confusing error message is raised: Invalid RGBA argument. Contrast this with the erro...
X Description: If the length of the c argument to matplotlib.pyplot.scatter doesn't match the size of the x and y arguments, a confusing error message is raised: Invalid RGBA argument. Contrast this with the ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/9209
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Passing an incorrectly sized colour list to scatter should raise a relevant error","articleBody":"If the length of the `c` argument to `matplotlib.pyplot.scatter` doesn't match the size of the `x` and `y` arguments, a confusing error message is raised: `Invalid RGBA argument`. Contrast this with the error that results if `x` and `y` are not the same size: `x and y must be the same size`. The error message for an incorrect size `c` array should be made more clear.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport numpy, matplotlib.pyplot as plt\r\nxs, ys = numpy.random.random((2, 10))\r\nc = numpy.random.random(9)\r\nplt.scatter(xs, ys, c=c)\r\n```\r\n\r\n**Actual outcome**\r\n\r\n```\r\n/usr/local/lib/python3.6/site-packages/matplotlib/colors.py in _to_rgba_no_colorcycle(c, alpha)\r\n 192 # float)` and `np.array(...).astype(float)` all convert \"0.5\" to 0.5.\r\n 193 # Test dimensionality to reject single floats.\r\n--\u003e 194 raise ValueError(\"Invalid RGBA argument: {!r}\".format(orig_c))\r\n 195 # Return a tuple to prevent the cached value from being modified.\r\n 196 c = tuple(c.astype(float))\r\n\r\nValueError: Invalid RGBA argument: 0.58430716187559439\r\n```\r\n\r\n**Expected outcome**\r\n\r\n```\r\nValueError: c and x must be the same size\r\n```\r\n\r\n * Matplotlib Version: 2.0.2\r\n * Python Version: 3.6.1","author":{"url":"https://github.com/MatthewJA","@type":"Person","name":"MatthewJA"},"datePublished":"2017-09-21T05:14:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/9209/matplotlib/issues/9209"}
| 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:6d523934-2641-8f41-a965-f9802a210bdb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A76E:996A:9C8456:E2F3D6:6A55F784 |
| html-safe-nonce | 66ba00f66aa469f736da2d63c6cf9a177b5457752a6ecee9e67ac2b914a8afe0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzZFOjk5NkE6OUM4NDU2OkUyRjNENjo2QTU1Rjc4NCIsInZpc2l0b3JfaWQiOiIzNjk5OTQ1OTczMTU5OTUwMjEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1c965be35a281602b26d32664d12d9a1cf2836f5945d996920a53008b63413bf |
| hovercard-subject-tag | issue:259377268 |
| 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/9209/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2c673b88594bff63da62d99082ef6fc14a2d5ff5c3541c1e2e21e62bf642fb6c/matplotlib/matplotlib/issues/9209 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2c673b88594bff63da62d99082ef6fc14a2d5ff5c3541c1e2e21e62bf642fb6c/matplotlib/matplotlib/issues/9209 |
| og:image:alt | If the length of the c argument to matplotlib.pyplot.scatter doesn't match the size of the x and y arguments, a confusing error message is raised: Invalid RGBA argument. Contrast this with the erro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MatthewJA |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 3725c7f9b2a6e3a27ef57c5aed13428c0f65e045 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width