Title: [Bug]: Duplicating the labels in the `height`/`width` argument in `barh()`/`bar` leads to undrawn bars · Issue #29507 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Duplicating the labels in the `height`/`width` argument in `barh()`/`bar` leads to undrawn bars · Issue #29507 · matplotlib/matplotlib
X Title: [Bug]: Duplicating the labels in the `height`/`width` argument in `barh()`/`bar` leads to undrawn bars · Issue #29507 · matplotlib/matplotlib
Description: Bug summary When there are duplicate labels in my label array (for example: ['first label', 'second label’, ‘third label', 'second label']), ax.bar() and ax.barh() ignore the duplicates (both bars and labels). Code for reproduction impor...
Open Graph Description: Bug summary When there are duplicate labels in my label array (for example: ['first label', 'second label’, ‘third label', 'second label']), ax.bar() and ax.barh() ignore the duplicates (both bars ...
X Description: Bug summary When there are duplicate labels in my label array (for example: ['first label', 'second label’, ‘third label', 'second label']), ax.bar() and ax.barh() ignore th...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29507
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Duplicating the labels in the `height`/`width` argument in `barh()`/`bar` leads to undrawn bars","articleBody":"### Bug summary\n\nWhen there are duplicate labels in my label array (for example: `['first label', 'second label’, ‘third label', 'second label']`), `ax.bar()` and `ax.barh()` ignore the duplicates (both bars and labels).\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\n\nname = [\n \"first label\",\n \"second label\",\n \"third label\",\n \"second label\",\n]\nvalue = [1, 2, 3, 4]\n\nfig, ax = plt.subplots(layout=\"tight\")\nax.barh(name, value)\n\nfor i in range(len(name)):\n n = name[i]\n v = value[i]\n ax.text(x=v + 1, y=i, s=f\"{n} ({i})\", va=\"center\")\n```\n\n### Actual outcome\n\n\n\n### Expected outcome\n\nA bar chart with 4 bars (the second ‘second label’ would be above the bar of the ‘third label’).\n\nWhat's more, for some reason the bar on the ‘second label’ has a value of 4, whereas I was intuitively expecting it to have a value of 2?\n\n### Additional information\n\nYou might expect there to be only single labels, but as this isn't explained in the documentation, I've pointed it out just in case. It's quite hard to spot when you're drawing a lot of bars.\n\n### Operating system\n\nMacOS Sonoma\n\n### Matplotlib Version\n\n3.10.0\n\n### Matplotlib Backend\n\nmodule://positron_ipykernel.matplotlib_backend\n\n### Python version\n\n3.13.1\n\n### Jupyter version\n\n/\n\n### Installation\n\npip","author":{"url":"https://github.com/JosephBARBIERDARNAL","@type":"Person","name":"JosephBARBIERDARNAL"},"datePublished":"2025-01-23T16:28:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/29507/matplotlib/issues/29507"}
| 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:750cefc0-c62e-a6ed-363c-d9bdb9e69b20 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D34:FDB96:EE8875:13FF556:6A51C58A |
| html-safe-nonce | eb703844c2b099970f2141d73afb4f12afb62a687c3dcf491ccd9addc876c087 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDM0OkZEQjk2OkVFODg3NToxM0ZGNTU2OjZBNTFDNThBIiwidmlzaXRvcl9pZCI6IjI0MDU3MjQwMzg4MzQwMTM1NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 07391115189db5cb8365354274c9c5f4fc0058e5acc0a2add2929f179dcb9c8a |
| hovercard-subject-tag | issue:2807369336 |
| 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/29507/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5bbaddc0518adfbda0521a584ec695034c37c50642c708a281cbf89394df88ec/matplotlib/matplotlib/issues/29507 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5bbaddc0518adfbda0521a584ec695034c37c50642c708a281cbf89394df88ec/matplotlib/matplotlib/issues/29507 |
| og:image:alt | Bug summary When there are duplicate labels in my label array (for example: ['first label', 'second label’, ‘third label', 'second label']), ax.bar() and ax.barh() ignore the duplicates (both bars ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JosephBARBIERDARNAL |
| 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