Title: pcolormesh x-axis with datetime broken for nearest shading · Issue #18547 · matplotlib/matplotlib · GitHub
Open Graph Title: pcolormesh x-axis with datetime broken for nearest shading · Issue #18547 · matplotlib/matplotlib
X Title: pcolormesh x-axis with datetime broken for nearest shading · Issue #18547 · matplotlib/matplotlib
Description: Bug report Bug summary When using a datetime x-axis in a pcolormesh, and nearest shading, TypeError: '>=' not supported between instances of 'datetime.timedelta' and 'int' is raised. From what I can tell, #18398 assumed comparison with 0...
Open Graph Description: Bug report Bug summary When using a datetime x-axis in a pcolormesh, and nearest shading, TypeError: '>=' not supported between instances of 'datetime.timedelta' and 'int' is raised. From what I ca...
X Description: Bug report Bug summary When using a datetime x-axis in a pcolormesh, and nearest shading, TypeError: '>=' not supported between instances of 'datetime.timedelta' and 'int'...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/18547
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pcolormesh x-axis with datetime broken for nearest shading","articleBody":"### Bug report\r\n\r\n\r\n**Bug summary**\r\n\r\nWhen using a datetime x-axis in a pcolormesh, and nearest shading,\r\n\r\n \u003e TypeError: '\u003e=' not supported between instances of 'datetime.timedelta' and 'int'\r\n\r\nis raised.\r\n\r\nFrom what I can tell, #18398 assumed comparison with 0 would always be possible, but this isn't the case for `datetime.timedelta`.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nfrom datetime import datetime\r\n\r\nfrom matplotlib import pyplot as plt\r\n\r\nx_coords = [datetime.fromtimestamp(x * 3600) for x in range(24)]\r\ny_coords = [*range(0, 10)]\r\nplt.pcolormesh(x_coords,\r\n y_coords, [[*range(24)] for _ in range(10)],\r\n shading=\"nearest\")\r\n```\r\n\r\n**Actual outcome**\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n File \".local/lib/python3.8/site-packages/matplotlib/pyplot.py\", line 2801, in pcolormesh\r\n __ret = gca().pcolormesh(\r\n File \".local/lib/python3.8/site-packages/matplotlib/__init__.py\", line 1438, in inner\r\n return func(ax, *map(sanitize_sequence, args), **kwargs)\r\n File \".local/lib/python3.8/site-packages/matplotlib/axes/_axes.py\", line 6093, in pcolormesh\r\n X, Y, C, shading = self._pcolorargs('pcolormesh', *args,\r\n File \".local/lib/python3.8/site-packages/matplotlib/axes/_axes.py\", line 5651, in _pcolorargs\r\n X = _interp_grid(X)\r\n File \".local/lib/python3.8/site-packages/matplotlib/axes/_axes.py\", line 5633, in _interp_grid\r\n if not (np.all(dX \u003e= 0) or np.all(dX \u003c= 0)):\r\nTypeError: '\u003e=' not supported between instances of 'datetime.timedelta' and 'int'\r\n```\r\n\r\n**Expected outcome**\r\n\r\nNone\r\n\r\n**Matplotlib version**\r\n\r\n * Matplotlib version: 3.3.2\r\n * Python version: 3.8\r\n\r\nworks with `pip3 install matplotlib==3.3.1`, fails with `pip3 install matplotlib==3.3.2`\r\n","author":{"url":"https://github.com/fthyssen","@type":"Person","name":"fthyssen"},"datePublished":"2020-09-23T09:15:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/18547/matplotlib/issues/18547"}
| 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:734b380d-e7da-b8ee-53ee-ff13b6fbaae0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA28:2D9C09:2BD8FD1:3BCBE9D:6A5453E5 |
| html-safe-nonce | f5f6883d4ff50a93f3aea839e35b3bc0144f1060da333bb2ddf8adb198c6b741 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTI4OjJEOUMwOToyQkQ4RkQxOjNCQ0JFOUQ6NkE1NDUzRTUiLCJ2aXNpdG9yX2lkIjoiNDcxMTMzNzIwMjg3MzAyOTYwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8352f981b41676fbfdc615a26f0945f06ece257e5b5e16a13935b8ffa6cbad9d |
| hovercard-subject-tag | issue:707191416 |
| 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/18547/issue_layout |
| twitter:image | https://opengraph.githubassets.com/69853d0700014b5b931c01a3dfaceda6e06dbd6cc5b3a43295637e9277380a05/matplotlib/matplotlib/issues/18547 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/69853d0700014b5b931c01a3dfaceda6e06dbd6cc5b3a43295637e9277380a05/matplotlib/matplotlib/issues/18547 |
| og:image:alt | Bug report Bug summary When using a datetime x-axis in a pcolormesh, and nearest shading, TypeError: '>=' not supported between instances of 'datetime.timedelta' and 'int' is raised. From what I ca... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fthyssen |
| 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