Title: [Bug]: broken_barh does not handle categorical axes very well · Issue #25133 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: broken_barh does not handle categorical axes very well · Issue #25133 · matplotlib/matplotlib
X Title: [Bug]: broken_barh does not handle categorical axes very well · Issue #25133 · matplotlib/matplotlib
Description: Bug summary When using broken_barh with a categorical (vertical) axis, there is no obvious way to specify the height of the bars. Unlike regular barh, float values do not work in the second argument position to specify heights. You can h...
Open Graph Description: Bug summary When using broken_barh with a categorical (vertical) axis, there is no obvious way to specify the height of the bars. Unlike regular barh, float values do not work in the second argumen...
X Description: Bug summary When using broken_barh with a categorical (vertical) axis, there is no obvious way to specify the height of the bars. Unlike regular barh, float values do not work in the second argumen...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25133
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: broken_barh does not handle categorical axes very well","articleBody":"### Bug summary\r\n\r\nWhen using broken_barh with a categorical (vertical) axis, there is no obvious way to specify the height of the bars. Unlike regular `barh`, float values do not work in the second argument position to specify heights.\r\n\r\nYou can hack it by using other categorical values (see example below), but this only works for integral heights and is generally yucky.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nfig, ax = plt.subplots()\r\n\r\nax.broken_barh([(0, 5-0), (10, 13-10)], ('car engine', 1))\r\nax.broken_barh([(3, 6-3), ], ('jackhammer', 1))\r\nax.broken_barh([(1, 4-1), ], ('children playing', 1))\r\n```\r\n\r\nAbove does not work. Substituting a categorical value (which maps to 1) does work:\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nfig, ax = plt.subplots()\r\n\r\n# 'jackhammer' is implicitly height=1 in this example\r\nax.broken_barh([(0, 5-0), (10, 13-10)], ('car engine', 'jackhammer'))\r\nax.broken_barh([(3, 6-3), ], ('jackhammer', 'jackhammer'))\r\nax.broken_barh([(1, 4-1), ], ('children playing', 'jackhammer'))\r\n```\r\n\r\n\r\n\r\n### Actual outcome\r\n\r\n```\r\nConversionError: Failed to convert value(s) to axis units: ('car engine', 1)\r\n```\r\n\r\n### Expected outcome\r\n\r\nIt should be possible to specify heights by numerical values as well as / instead of categorical positions.\r\n\r\n### Additional information\r\n\r\nFor broader context, the full description of my use case is at https://discourse.matplotlib.org/t/advice-for-using-broken-bar-collections-with-categorical-axes/23171?u=brian.mcfee\r\n\r\nBest guess for fix: set this up however it was done over in barh :shrug: \r\n\r\nProbably this also affects broken_bar (vertical) as well.\r\n\r\n### Operating system\r\n\r\n_No response_\r\n\r\n### Matplotlib Version\r\n\r\n3.6.3\r\n\r\n### Matplotlib Backend\r\n\r\n_No response_\r\n\r\n### Python version\r\n\r\n_No response_\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/bmcfee","@type":"Person","name":"bmcfee"},"datePublished":"2023-02-02T18:44:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/25133/matplotlib/issues/25133"}
| 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:a2c544d2-35d3-de6d-c082-780c105a8d73 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C0C:FDB96:EDBFB6:13EE2E2:6A51C53D |
| html-safe-nonce | c132541b4c371e5769f546984a0de1715a97aab42f54baf0a4efb72b19f7f718 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzBDOkZEQjk2OkVEQkZCNjoxM0VFMkUyOjZBNTFDNTNEIiwidmlzaXRvcl9pZCI6IjIzODgxODA0ODQ3MDQyOTAxMDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 484b018ea0cc4a6e50910911f9d3e5f2da0d6d1af1041262593cecc60752de86 |
| hovercard-subject-tag | issue:1568589101 |
| 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/25133/issue_layout |
| twitter:image | https://opengraph.githubassets.com/be199dc3e2311cb874703eae51ffea32e2a1d1d5365e79881b1e8e55a1dd5519/matplotlib/matplotlib/issues/25133 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/be199dc3e2311cb874703eae51ffea32e2a1d1d5365e79881b1e8e55a1dd5519/matplotlib/matplotlib/issues/25133 |
| og:image:alt | Bug summary When using broken_barh with a categorical (vertical) axis, there is no obvious way to specify the height of the bars. Unlike regular barh, float values do not work in the second argumen... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bmcfee |
| 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