Title: [Bug]: grouped_bar can pass label and color twice, causing TypeError · Issue #30739 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: grouped_bar can pass label and color twice, causing TypeError · Issue #30739 · matplotlib/matplotlib
X Title: [Bug]: grouped_bar can pass label and color twice, causing TypeError · Issue #30739 · matplotlib/matplotlib
Description: Bug summary In the current implementation of Axes.grouped_bar, calling the function with label or color keyword arguments can result in a TypeError: matplotlib.axes._axes.Axes.bar() got multiple values for keyword argument 'label'. This ...
Open Graph Description: Bug summary In the current implementation of Axes.grouped_bar, calling the function with label or color keyword arguments can result in a TypeError: matplotlib.axes._axes.Axes.bar() got multiple va...
X Description: Bug summary In the current implementation of Axes.grouped_bar, calling the function with label or color keyword arguments can result in a TypeError: matplotlib.axes._axes.Axes.bar() got multiple va...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30739
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: grouped_bar can pass label and color twice, causing TypeError","articleBody":"### Bug summary\n\nIn the current implementation of Axes.grouped_bar, calling the function with label or color keyword arguments can result in a TypeError: matplotlib.axes._axes.Axes.bar() got multiple values for keyword argument 'label'.\n\nThis happens because grouped_bar explicitly passes label and color to self.bar(), while kwargs may also contain these keys if the caller provided them. Python then sees two values for the same keyword argument.\n\nExample that triggers the error:\n\n```\nfig, ax = plt.subplots()\nx = np.arange(2)\nheights = [np.array([1, 2]), np.array([2, 3])]\n\nax.grouped_bar(\n heights,\n positions=x,\n label=\"dataset\",\n color=[\"red\", \"blue\"]\n)\n# TypeError: Axes.bar() got multiple values for keyword argument 'label'\n```\n\nCause\nInside grouped_bar:\n\n```\nbc = self.bar(lefts, hs, width=bar_width, align=\"edge\",\n label=label, color=color, **kwargs)\n```\n\nIf kwargs also contains label or color, bar() receives the same argument twice.\nThis can occur:\nWhen the caller passes label or color explicitly.\nWhen a DataFrame or dict input automatically generates labels internally, and kwargs contains the same keys.\n\n\n\n### Code for reproduction\n\n```Python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfig, ax = plt.subplots()\nx = np.arange(2)\nheights = [np.array([1, 2]), np.array([2, 3])]\n\n# This triggers the TypeError\nax.grouped_bar(\n heights,\n positions=x,\n label=\"dataset\",\n color=[\"red\", \"blue\"]\n)\n```\n\n### Actual outcome\n\nTypeError: matplotlib.axes._axes.Axes.bar() got multiple values for keyword argument 'label'\n\n\u003cimg width=\"1217\" height=\"701\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/c2125843-464a-4913-a4ff-094a876efb60\" /\u003e\n\n### Expected outcome\n\nA grouped bar plot with two groups, each group having two bars colored red and blue, and a legend showing \"dataset\" for the bars.\n\n### Additional information\n\nThis bug happens whenever label or color is explicitly passed in kwargs to grouped_bar.\nIt can also happen with a pandas DataFrame input if labels are automatically assigned internally.\n\n### Operating system\n\nmacOS\n\n### Matplotlib Version\n\n3.11.0.dev1467+gdb83efff4.d20251111\n\n### Matplotlib Backend\n\nmacosx\n\n### Python version\n\n3.13.7\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/ilakkmanoharan","@type":"Person","name":"ilakkmanoharan"},"datePublished":"2025-11-11T00:55:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/30739/matplotlib/issues/30739"}
| 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:683f6ee9-17d0-1135-ce07-7da21d9076ab |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E256:1E5BA8:2A99B7:3960EA:6A54016F |
| html-safe-nonce | a93955c0bebdef2eb151b80643f71ee79d579970e2ef98db2dea4b054c6c2f54 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjU2OjFFNUJBODoyQTk5Qjc6Mzk2MEVBOjZBNTQwMTZGIiwidmlzaXRvcl9pZCI6IjYxNjY2NTk3MDExNTk0OTM5OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 92bc713f61c20a063f19c50824d4f27faec027473d73e1b9e4ac9363fde332be |
| hovercard-subject-tag | issue:3610239546 |
| 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/30739/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6fc20efe1488e2a0fd4c30f696af67094122b3d5ebb60a8c66d075de0eff6669/matplotlib/matplotlib/issues/30739 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6fc20efe1488e2a0fd4c30f696af67094122b3d5ebb60a8c66d075de0eff6669/matplotlib/matplotlib/issues/30739 |
| og:image:alt | Bug summary In the current implementation of Axes.grouped_bar, calling the function with label or color keyword arguments can result in a TypeError: matplotlib.axes._axes.Axes.bar() got multiple va... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilakkmanoharan |
| 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