Title: [Bug/TYPE]: Scatter `c` Typehint does not support list of numbers when using `cmap` · Issue #26936 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug/TYPE]: Scatter `c` Typehint does not support list of numbers when using `cmap` · Issue #26936 · matplotlib/matplotlib
X Title: [Bug/TYPE]: Scatter `c` Typehint does not support list of numbers when using `cmap` · Issue #26936 · matplotlib/matplotlib
Description: Bug summary type-checking failing when using something like this: plt.scatter(x_coords, y_coords, c=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], cmap='jet_r', alpha=0.6) saying that c has incompatible types: error: Argument "c" to "scatter" has incom...
Open Graph Description: Bug summary type-checking failing when using something like this: plt.scatter(x_coords, y_coords, c=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], cmap='jet_r', alpha=0.6) saying that c has incompatible types: er...
X Description: Bug summary type-checking failing when using something like this: plt.scatter(x_coords, y_coords, c=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], cmap='jet_r', alpha=0.6) saying that c has incompatible t...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/26936
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug/TYPE]: Scatter `c` Typehint does not support list of numbers when using `cmap`","articleBody":"### Bug summary\n\ntype-checking failing when using something like this:\r\n```\r\nplt.scatter(x_coords, y_coords, c=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], cmap='jet_r', alpha=0.6)\r\n```\r\n\r\nsaying that `c` has incompatible types:\r\n```\r\nerror: Argument \"c\" to \"scatter\" has incompatible type \"list[float]\"; expected \"Sequence[tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]] | tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None\"\r\n```\r\n\r\nHowever, this actually IS allowed by underlying code for plotting since `c` will sample from the `cmap` function.\r\n\r\nI suspect this will happen in any plotting function that allows this behavior.\n\n### Code for reproduction\n\n```python\nplt.scatter([1,2,3,4,5], [1,2,3,4,5], c=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], cmap='jet_r', alpha=0.6)\n```\n\n\n### Actual outcome\n\nmypy raises error:\r\n```\r\nerror: Argument \"c\" to \"scatter\" has incompatible type \"list[float]\"; expected \"Sequence[tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]] | tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None\"\r\n```\n\n### Expected outcome\n\nmypy should not raise error\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.8.0\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\nNone","author":{"url":"https://github.com/evgenyslab","@type":"Person","name":"evgenyslab"},"datePublished":"2023-09-27T17:52:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/26936/matplotlib/issues/26936"}
| 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:9d20d415-8e40-b772-66c8-8f8e403b567b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B0B8:3F3173:87075D:B7A87C:6A56EEB6 |
| html-safe-nonce | c6bc52f53971e177c4d8f64c4ae4da8ebd6de7d5da0cb4ca0728c84c12b1b0c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEI4OjNGMzE3Mzo4NzA3NUQ6QjdBODdDOjZBNTZFRUI2IiwidmlzaXRvcl9pZCI6IjQ5MTM3MDkzOTYwNzE0NzY5MTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1616745c3d529773b16ddbe6dae26eee9367029b337b6fa1f09ca50ed5bddbdd |
| hovercard-subject-tag | issue:1916057285 |
| 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/26936/issue_layout |
| twitter:image | https://opengraph.githubassets.com/52d0c3899c6306ce483d1c5b0fdee58ed7b63a82378825a25e7d2a8a85caf7d2/matplotlib/matplotlib/issues/26936 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/52d0c3899c6306ce483d1c5b0fdee58ed7b63a82378825a25e7d2a8a85caf7d2/matplotlib/matplotlib/issues/26936 |
| og:image:alt | Bug summary type-checking failing when using something like this: plt.scatter(x_coords, y_coords, c=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], cmap='jet_r', alpha=0.6) saying that c has incompatible types: er... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | evgenyslab |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5220a278731283038daf0ed00b41f06ef7ff9539020ecc806c5c5a0fb6bda25a |
| 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 | 8684ae1a81cd3e4ef219b241179982bbda1a5b1f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width