Title: [Bug]: boxplot errors when `x` and `tick_labels` are empty · Issue #32304 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: boxplot errors when `x` and `tick_labels` are empty · Issue #32304 · matplotlib/matplotlib
X Title: [Bug]: boxplot errors when `x` and `tick_labels` are empty · Issue #32304 · matplotlib/matplotlib
Description: Bug summary boxplot errors when the arguments x and tick_labels are both empty. Code for reproduction from matplotlib import pyplot as plt plt.boxplot([], tick_labels=[]) Actual outcome Traceback (most recent call last): File "
Open Graph Description: Bug summary boxplot errors when the arguments x and tick_labels are both empty. Code for reproduction from matplotlib import pyplot as plt plt.boxplot([], tick_labels=[]) Actual outcome Traceback (...
X Description: Bug summary boxplot errors when the arguments x and tick_labels are both empty. Code for reproduction from matplotlib import pyplot as plt plt.boxplot([], tick_labels=[]) Actual outcome Traceback (...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/32304
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: boxplot errors when `x` and `tick_labels` are empty","articleBody":"### Bug summary\n\n[`boxplot`](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html) errors when the arguments `x` and `tick_labels` are both empty.\n\n### Code for reproduction\n\n```Python\nfrom matplotlib import pyplot as plt\n\nplt.boxplot([], tick_labels=[])\n```\n\n### Actual outcome\n\n```\nTraceback (most recent call last):\n File \"\u003cstring>\", line 1, in \u003cmodule>\n from matplotlib import pyplot as plt; plt.boxplot([], tick_labels=[])\n ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.14/site-packages/matplotlib/_api/deprecation.py\", line 477, in wrapper\n return func(*args, **kwargs)\n File \"/venv/lib/python3.14/site-packages/matplotlib/pyplot.py\", line 3234, in boxplot\n return gca().boxplot(\n ~~~~~~~~~~~~~^\n x,\n ^^\n ...\u003c28 lines>...\n **({\"data\": data} if data is not None else {}),\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/venv/lib/python3.14/site-packages/matplotlib/_api/deprecation.py\", line 477, in wrapper\n return func(*args, **kwargs)\n File \"/venv/lib/python3.14/site-packages/matplotlib/__init__.py\", line 1528, in inner\n return func(\n ax,\n *map(cbook.sanitize_sequence, args),\n **{k: cbook.sanitize_sequence(v) for k, v in kwargs.items()})\n File \"/venv/lib/python3.14/site-packages/matplotlib/axes/_axes.py\", line 4541, in boxplot\n bxpstats = cbook.boxplot_stats(x, whis=whis, bootstrap=bootstrap,\n labels=tick_labels, autorange=autorange)\n File \"/venv/lib/python3.14/site-packages/matplotlib/cbook.py\", line 1269, in boxplot_stats\n raise ValueError(\"Dimensions of labels and X must be compatible\")\nValueError: Dimensions of labels and X must be compatible\n```\n\n### Expected outcome\n\nDrawing nothing, without crashing.\n\n### Additional information\n\nThe error is raised [here](https://github.com/matplotlib/matplotlib/blob/f3877c54e25baefc2605d6260cb7ef44b5edbb12/lib/matplotlib/cbook.py#L1268).\n\nThis happens because `_reshape_2D([], \"X\")` is returning `[[]]`, which has a `len` of 1 rather than 0.\n\n### Operating system\n\nmacOS Tahoe 26.5.2\n\n### Matplotlib Version\n\n3.11.1\n\n### Matplotlib Backend\n\nmacosx\n\n### Python version\n\nPython 3.14.6\n\n### Jupyter version\n\n7.6.0\n\n### Installation\n\npip","author":{"url":"https://github.com/carlosgmartin","@type":"Person","name":"carlosgmartin"},"datePublished":"2026-09-05T18:11:03Z","url":"https://github.com/matplotlib/matplotlib/issues/32304"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:fd69a330-d616-f971-aad8-105652ff53d9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9246:33DDEF:1CE2530:276E7E2:6B00166A |
| html-safe-nonce | 03e3b1aa932f8de93a78292ad7aa60bb7cc0e9ebd7d1d7b3dcddf497a236f1cb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjQ2OjMzRERFRjoxQ0UyNTMwOjI3NkU3RTI6NkIwMDE2NkEiLCJ2aXNpdG9yX2lkIjoiNTMwMjM5NDMyNzUwNTM2Mjk4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e18926425e2fe1e3b0d1098352781268d2c03ad516e30cbf9b98a8d81c1680ec |
| hovercard-subject-tag | issue:5359963836 |
| 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/32304/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56f209459b7531381ed9ac38a7ab094f46be1fcfbefae8b7394309ef10d7bbfe/matplotlib/matplotlib/issues/32304 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56f209459b7531381ed9ac38a7ab094f46be1fcfbefae8b7394309ef10d7bbfe/matplotlib/matplotlib/issues/32304 |
| og:image:alt | Bug summary boxplot errors when the arguments x and tick_labels are both empty. Code for reproduction from matplotlib import pyplot as plt plt.boxplot([], tick_labels=[]) Actual outcome Traceback (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | carlosgmartin |
| hostname | github.com |
| expected-hostname | github.com |
| None | a2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4 |
| 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 | 70121d4e855ee0bb7b75cf15d061d91f8863c0f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width