Title: [ENH]: Legend entries for boxplot · Issue #27792 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: Legend entries for boxplot · Issue #27792 · matplotlib/matplotlib
X Title: [ENH]: Legend entries for boxplot · Issue #27792 · matplotlib/matplotlib
Description: Problem Currently, boxplots do not get legend entries. #27711 was an attempt to introduce them but only solved one very particular usecase and did not generalize well. See #27780. There is a labels parameter, but that only sets x-tick la...
Open Graph Description: Problem Currently, boxplots do not get legend entries. #27711 was an attempt to introduce them but only solved one very particular usecase and did not generalize well. See #27780. There is a labels...
X Description: Problem Currently, boxplots do not get legend entries. #27711 was an attempt to introduce them but only solved one very particular usecase and did not generalize well. See #27780. There is a labels...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/27792
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: Legend entries for boxplot","articleBody":"### Problem\r\n\r\nCurrently, boxplots do not get legend entries. #27711 was an attempt to introduce them but only solved one very particular usecase and did not generalize well. See https://github.com/matplotlib/matplotlib/pull/27780.\r\n\r\nThere is a `labels` parameter, but that only sets x-tick labels. And it has one entry per box. For the legend we should have only one entry per `boxplot()` call no matter how many boxes that has, because `boxplot` draws N identically styled boxes and it does not make sense to have N identical handles with different labels.\r\n\r\nBecause of the x-tick relation of `labels` and it's relation to individual boxes, this parameter is not suited for the legend labels. \r\n\r\n### Proposed solution\r\n\r\nWe need a separate parameter. There are basically two options:\r\n\r\n#### Variant 1) `legend_label: str`\r\n\r\n*pro*: simple and clear, no interference with the existing API\r\n*con*: inconsistent with the rest of the library: all other functions use `label` for the legend entry.\r\n\r\n\r\n#### Variant 2) `label: str`\r\n*pro*: consistent with the rest of the library\r\n*con*: Having `label` alongside `labels` is quite confusing and easily leads to errors. (We could runtime-check for the type str vs list of str, to give helpful error messages but still ...)\r\nIf we want to go this way, we should rename `labels` to `tick_labels` or similar.\r\n","author":{"url":"https://github.com/timhoffm","@type":"Person","name":"timhoffm"},"datePublished":"2024-02-14T20:04:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/27792/matplotlib/issues/27792"}
| 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:c7191dd2-ce34-b4cd-deda-b8ebcd408a40 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA82:2F227:2B0C7D:394D2E:6A5228A9 |
| html-safe-nonce | a6e2eab722f02953e55fca7408fc5abfb18b9a15d49efa7816f98244e4452841 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTgyOjJGMjI3OjJCMEM3RDozOTREMkU6NkE1MjI4QTkiLCJ2aXNpdG9yX2lkIjoiNzczNTQ3NjIwMzQzNjUxNzU0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 83291d24d3f99d14fa5a7b9353fdfb67856cb7b3fa107b72f68b9cc07031706c |
| hovercard-subject-tag | issue:2135113929 |
| 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/27792/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7f514008a02b84075fa0ac8e11b85a58ebffe714269826c13dfbfb07229dbc52/matplotlib/matplotlib/issues/27792 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7f514008a02b84075fa0ac8e11b85a58ebffe714269826c13dfbfb07229dbc52/matplotlib/matplotlib/issues/27792 |
| og:image:alt | Problem Currently, boxplots do not get legend entries. #27711 was an attempt to introduce them but only solved one very particular usecase and did not generalize well. See #27780. There is a labels... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timhoffm |
| 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