Title: A reasonable default width for bar() with units? · Issue #13236 · matplotlib/matplotlib · GitHub
Open Graph Title: A reasonable default width for bar() with units? · Issue #13236 · matplotlib/matplotlib
X Title: A reasonable default width for bar() with units? · Issue #13236 · matplotlib/matplotlib
Description: In #12903 we merged a PR fixing the handling of the default width (0.8) when bar (barh, broken_barh) is called with unitized data (I was among the PR approvers; see also #13187 as followup). Briefly, the idea is to support both unitless ...
Open Graph Description: In #12903 we merged a PR fixing the handling of the default width (0.8) when bar (barh, broken_barh) is called with unitized data (I was among the PR approvers; see also #13187 as followup). Briefl...
X Description: In #12903 we merged a PR fixing the handling of the default width (0.8) when bar (barh, broken_barh) is called with unitized data (I was among the PR approvers; see also #13187 as followup). Briefl...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/13236
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A reasonable default width for bar() with units?","articleBody":"In #12903 we merged a PR fixing the handling of the default `width` (0.8) when `bar` (`barh`, `broken_barh`) is called with unitized data (I was among the PR approvers; see also #13187 as followup). Briefly, the idea is to support both unitless and unitized widths, so that one can do\r\n```\r\nbar([dates]) # default width: 0.8\r\nbar([dates], width=[timedeltas]) # or single timedelta\r\nbar([categoricals]) # default width: 0.8\r\nbar([categoricals], width=[unitless]) # or single scalar\r\n```\r\nThe main trickiness is that the default width is unitless (0.8), but one can also pass a unitful width, so it's not clear how to add it to the unitized `x`; moreover, note that the unit of `x` can either correctly handle addition (time + timedelta), or not (categoricals, which need to go through the converter first). So the end design is something like\r\n```\r\ntry:\r\n dx = deunitize(orig_x + orig_dx) - deunitize(orig_x)\r\nexcept ...:\r\n dx = deunitize(orig_dx)\r\n```\r\nwhere orig_x and orig_dx are the user inputs, either unitized or deunitized.\r\n\r\nHowever, I now feel like this is not really looking at the problem under the right angle: if the user input is unitized, what's the chance that 0.8 \"deunitized-units\" is a reasonable default width? It is rather low, I would guess. Instead, it would seem that the intent of the default would/should be \"0.8 times the spacing between the bars\" (in the common case of evenly spaced bars).\r\n\r\nHence, a solution may perhaps be to change the interpretation of a unitless `width` in the case of unitized data, to have it mean (e.g.) a fraction of the (mean) spacing between the bars (i.e. `(max(x) - min(x)) / (n - 1)`). Note that because `bar` did not support unitized data up to now, there are no backcompat concerns.\r\n\r\nMostly @jklymak I guess. Allowing myself to mark this as release critical mostly so that we don't have to go through a painful deprecation period if we agree on this, but feel free to untag.","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2019-01-20T06:37:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":41},"url":"https://github.com/13236/matplotlib/issues/13236"}
| 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:0f5db074-b39a-fff3-a6ca-71c89f6dc2ae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD1A:1CCBDE:2DB840D:3E35F70:6A53D3D7 |
| html-safe-nonce | b4632965a9f910c2b47ed75f31f422ff71e9c8ab725b6afa34df9323807496b1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDFBOjFDQ0JERToyREI4NDBEOjNFMzVGNzA6NkE1M0QzRDciLCJ2aXNpdG9yX2lkIjoiNjc4MjA4ODcyNjA5OTI1MjE4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 06b0e5617a047688f4755bbb387e577bb298d8e1cf17062407b3e9e8d3a682b9 |
| hovercard-subject-tag | issue:401067973 |
| 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/13236/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0360bee50834709549c91eab0e5fa82746f9da9703e0729322cbab98ba558910/matplotlib/matplotlib/issues/13236 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0360bee50834709549c91eab0e5fa82746f9da9703e0729322cbab98ba558910/matplotlib/matplotlib/issues/13236 |
| og:image:alt | In #12903 we merged a PR fixing the handling of the default width (0.8) when bar (barh, broken_barh) is called with unitized data (I was among the PR approvers; see also #13187 as followup). Briefl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| 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