Title: [ENH]: Support using datetimes as `positions` argument to violin(...) · Issue #30417 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: Support using datetimes as `positions` argument to violin(...) · Issue #30417 · matplotlib/matplotlib
X Title: [ENH]: Support using datetimes as `positions` argument to violin(...) · Issue #30417 · matplotlib/matplotlib
Description: Problem It should be possible to set the position of a violin plot to be a datetime, but currently this fails: import datetime import matplotlib.pyplot as plt fig, ax = plt.subplots() datetimes = [ datetime.datetime(2023, 2, 10), datetim...
Open Graph Description: Problem It should be possible to set the position of a violin plot to be a datetime, but currently this fails: import datetime import matplotlib.pyplot as plt fig, ax = plt.subplots() datetimes = [...
X Description: Problem It should be possible to set the position of a violin plot to be a datetime, but currently this fails: import datetime import matplotlib.pyplot as plt fig, ax = plt.subplots() datetimes = [...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30417
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: Support using datetimes as `positions` argument to violin(...)","articleBody":"### Problem\n\nIt should be possible to set the position of a violin plot to be a datetime, but currently this fails:\n\n```python\nimport datetime\n\nimport matplotlib.pyplot as plt\n\nfig, ax = plt.subplots()\ndatetimes = [\n datetime.datetime(2023, 2, 10),\n datetime.datetime(2023, 5, 18),\n datetime.datetime(2023, 6, 6)\n]\nax.violin(\n [\n {\n 'coords': datetimes,\n 'vals': [0.1, 0.5, 0.2],\n 'mean': datetimes[1],\n 'median': datetimes[1],\n 'min': datetimes[0],\n 'max': datetimes[-1],\n 'quantiles': datetimes\n }\n ],\n positions=[datetime.datetime(2020, 1, 1)]\n)\n```\n\n```python\nTraceback (most recent call last):\n File \"/Users/dstansby/software/mpl/matplotlib/test.py\", line 11, in \u003cmodule\u003e\n ax.violin(\n File \"/Users/dstansby/miniforge3/envs/mpl-dev/lib/python3.12/site-packages/matplotlib/_api/deprecation.py\", line 453, in wrapper\n return func(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/dstansby/miniforge3/envs/mpl-dev/lib/python3.12/site-packages/matplotlib/axes/_axes.py\", line 9064, in violin\n line_ends = [[-0.25 if side in ['both', 'low'] else 0],\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nTypeError: unsupported operand type(s) for +: 'float' and 'datetime.datetime'\n```\n\n### Proposed solution\n\n_No response_","author":{"url":"https://github.com/dstansby","@type":"Person","name":"dstansby"},"datePublished":"2025-08-12T10:50:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/30417/matplotlib/issues/30417"}
| 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:9b443e23-7116-c76e-f843-e2baaf5847f2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 86DC:3A796C:AE2436:E9BD7B:6A531D0A |
| html-safe-nonce | 61ac7f270722ab9a670507b7574a673f1e7ad9c511b7fbf6af00036408b7d3f7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkRDOjNBNzk2QzpBRTI0MzY6RTlCRDdCOjZBNTMxRDBBIiwidmlzaXRvcl9pZCI6IjUwNjQ0OTQ3NTg1NTIwODM3MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e04869de3d9ccfba9c59226eb6e7e0d26d56c7d33ee3546b1ea19b71bde3f5ed |
| hovercard-subject-tag | issue:3313677456 |
| 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/30417/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cb961d62c8de31c8f2e60de8dd28784e12ae206d28e62c8e934f6dcc091877f7/matplotlib/matplotlib/issues/30417 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cb961d62c8de31c8f2e60de8dd28784e12ae206d28e62c8e934f6dcc091877f7/matplotlib/matplotlib/issues/30417 |
| og:image:alt | Problem It should be possible to set the position of a violin plot to be a datetime, but currently this fails: import datetime import matplotlib.pyplot as plt fig, ax = plt.subplots() datetimes = [... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dstansby |
| 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