Title: pcolormesh throws UFuncTypeError if np.datetime64() and shading='nearest · Issue #19191 · matplotlib/matplotlib · GitHub
Open Graph Title: pcolormesh throws UFuncTypeError if np.datetime64() and shading='nearest · Issue #19191 · matplotlib/matplotlib
X Title: pcolormesh throws UFuncTypeError if np.datetime64() and shading='nearest · Issue #19191 · matplotlib/matplotlib
Description: Bug report Bug summary For people who use numpy.datetime64() arrays with pcolormesh, a DeprecationWarning has been appearing prompting users to specify a shading kwarg 'nearest', 'auto' or 'gouraud' since shading='flat' is being deprecat...
Open Graph Description: Bug report Bug summary For people who use numpy.datetime64() arrays with pcolormesh, a DeprecationWarning has been appearing prompting users to specify a shading kwarg 'nearest', 'auto' or 'gouraud...
X Description: Bug report Bug summary For people who use numpy.datetime64() arrays with pcolormesh, a DeprecationWarning has been appearing prompting users to specify a shading kwarg 'nearest', 'auto&...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19191
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pcolormesh throws UFuncTypeError if np.datetime64() and shading='nearest","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\n\r\nFor people who use numpy.datetime64() arrays with pcolormesh, a DeprecationWarning has been appearing prompting users to specify a shading kwarg 'nearest', 'auto' or 'gouraud' since shading='flat' is being deprecated. However, passing 'nearest' results in a UFuncTypeError when using 'nearest' due to a casting issue in _axes.py from _interp_grid()\r\n\r\n**Code for reproduction**\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ntimes = np.arange(np.datetime64('2020-12-01'), np.datetime64('2020-12-31'))\r\nyaxis = np.arange(0, 20)\r\ncaxis = np.random.normal(0.0, 1.0, (times.shape[0], yaxis.shape[0]))\r\n\r\nplt.pcolormesh(times, yaxis, caxis.T, shading='nearest')\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n```\r\nTraceback (most recent call last):\r\n\r\n File \"..\\test.py\", line 15, in \u003cmodule\u003e\r\n plt.pcolormesh(times, yaxis, caxis.T, shading='nearest')\r\n\r\n File \"C:\\Users\\iarey\\anaconda3\\lib\\site-packages\\matplotlib\\pyplot.py\", line 2801, in pcolormesh\r\n __ret = gca().pcolormesh(\r\n\r\n File \"C:\\Users\\iarey\\anaconda3\\lib\\site-packages\\matplotlib\\__init__.py\", line 1438, in inner\r\n return func(ax, *map(sanitize_sequence, args), **kwargs)\r\n\r\n File \"C:\\Users\\iarey\\anaconda3\\lib\\site-packages\\matplotlib\\axes\\_axes.py\", line 6093, in pcolormesh\r\n X, Y, C, shading = self._pcolorargs('pcolormesh', *args,\r\n\r\n File \"C:\\Users\\iarey\\anaconda3\\lib\\site-packages\\matplotlib\\axes\\_axes.py\", line 5651, in _pcolorargs\r\n X = _interp_grid(X)\r\n\r\n File \"C:\\Users\\iarey\\anaconda3\\lib\\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\n\r\nUFuncTypeError: Cannot cast ufunc 'greater_equal' input 0 from dtype('\u003cm8[D]') to dtype('\u003cm8') with casting rule 'same_kind'\r\n```\r\n\r\n**Expected outcome**\r\nA pcolormesh timeseries plot with random data and a np.datetime64() x-axis.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: Windows 10\r\n * Matplotlib version: 3.3.2 via standard conda\r\n * Matplotlib backend: Qt5Agg\r\n * Python version: 3.8.5\r\n * Jupyter version (if applicable):\r\n * Other libraries: numpy-1.19.2","author":{"url":"https://github.com/Yoshi2112","@type":"Person","name":"Yoshi2112"},"datePublished":"2020-12-29T10:57:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/19191/matplotlib/issues/19191"}
| 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:4338a70f-1e23-8475-ed87-3274edf58d4a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBEA:23560F:2D80D8F:3E0998D:6A53D38F |
| html-safe-nonce | 948f91c474daebe21b5de00439e3cff71e59bf98553c5d07b0e48825992945be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkVBOjIzNTYwRjoyRDgwRDhGOjNFMDk5OEQ6NkE1M0QzOEYiLCJ2aXNpdG9yX2lkIjoiODkwMTE2MzI4NzE1MDA1NjMzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7c9d7f35154b897c9effbb24ab2f52e4f0eb9b6d4ce21643b58cd2719298700b |
| hovercard-subject-tag | issue:775831119 |
| 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/19191/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4683d63d0905e2be738481b7f5b386f88809901a828438de3f8dfadc0553aaea/matplotlib/matplotlib/issues/19191 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4683d63d0905e2be738481b7f5b386f88809901a828438de3f8dfadc0553aaea/matplotlib/matplotlib/issues/19191 |
| og:image:alt | Bug report Bug summary For people who use numpy.datetime64() arrays with pcolormesh, a DeprecationWarning has been appearing prompting users to specify a shading kwarg 'nearest', 'auto' or 'gouraud... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Yoshi2112 |
| 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