Title: ax.bar doesn't work correctly when width is a timedelta64 object · Issue #11290 · matplotlib/matplotlib · GitHub
Open Graph Title: ax.bar doesn't work correctly when width is a timedelta64 object · Issue #11290 · matplotlib/matplotlib
X Title: ax.bar doesn't work correctly when width is a timedelta64 object · Issue #11290 · matplotlib/matplotlib
Description: The following example In [1]: x = np.array(range(100), dtype='M8[D]') In [2]: ax = plt.subplot(1,1,1) In [3]: y = np.random.random(100) In [4]: ax.bar(x, y) Out[4]:
Open Graph Description: The following example In [1]: x = np.array(range(100), dtype='M8[D]') In [2]: ax = plt.subplot(1,1,1) In [3]: y = np.random.random(100) In [4]: ax.bar(x, y) Out[4]: X Description: The following example In [1]: x = np.array(range(100), dtype='M8[D]') In [2]: ax = plt.subplot(1,1,1) In [3]: y = np.random.random(100) In [4]: ax.bar(x, y) Out[4]: <BarContainer object ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/11290
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ax.bar doesn't work correctly when width is a timedelta64 object","articleBody":"The following example\r\n\r\n```python\r\nIn [1]: x = np.array(range(100), dtype='M8[D]')\r\n\r\nIn [2]: ax = plt.subplot(1,1,1)\r\n\r\nIn [3]: y = np.random.random(100)\r\n\r\nIn [4]: ax.bar(x, y)\r\nOut[4]: \u003cBarContainer object of 100 artists\u003e\r\n```\r\n\r\nworks fine, but if I set width to be the diff of the ``datetime64`` array, which gives a ``timedelta64`` array, things break:\r\n\r\n```python\r\nIn [7]: ax.bar(x[:-1], y[:-1], width=np.diff(x))\r\n---------------------------------------------------------------------------\r\nTypeError Traceback (most recent call last)\r\n\u003cipython-input-7-f05692d600cb\u003e in \u003cmodule\u003e()\r\n----\u003e 1 ax.bar(x[:-1], y[:-1], width=np.diff(x))\r\n\r\n~/miniconda3/envs/dev/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)\r\n 1853 \"the Matplotlib list!)\" % (label_namer, func.__name__),\r\n 1854 RuntimeWarning, stacklevel=2)\r\n-\u003e 1855 return func(ax, *args, **kwargs)\r\n 1856 \r\n 1857 inner.__doc__ = _add_data_doc(inner.__doc__,\r\n\r\n~/miniconda3/envs/dev/lib/python3.6/site-packages/matplotlib/axes/_axes.py in bar(self, *args, **kwargs)\r\n 2257 if align == 'center':\r\n 2258 if orientation == 'vertical':\r\n-\u003e 2259 left = x - width / 2\r\n 2260 bottom = y\r\n 2261 elif orientation == 'horizontal':\r\n\r\nTypeError: ufunc subtract cannot use operands with types dtype('float64') and dtype('\u003cm8[D]')\r\n```\r\n\r\nThis should however be unambiguous, so it would be nice if it worked.","author":{"url":"https://github.com/astrofrog","@type":"Person","name":"astrofrog"},"datePublished":"2018-05-22T21:18:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/11290/matplotlib/issues/11290"}
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:29783ea5-8eda-a6ed-ffdf-c971f6cc00a0 current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id 8E14:171A20:22E6FDF:2F7BD8B:6A539A20 html-safe-nonce 205e560a500acd452040bb6acf57644fcbab15949ba294e2ba4dc4e9434eac4a visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTE0OjE3MUEyMDoyMkU2RkRGOjJGN0JEOEI6NkE1MzlBMjAiLCJ2aXNpdG9yX2lkIjoiNTA0MzQ3OTk4NjA4Mzk2MTM3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 visitor-hmac 686ce43251c1c453c901849172a17514e20a5e85d8461c22f4c32c2617d14694 hovercard-subject-tag issue:325466915 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/11290/issue_layout twitter:image https://opengraph.githubassets.com/a6371a2c818e19538aea7b9f6cdcd5461ebc5e4adaccde65773b42003689ae14/matplotlib/matplotlib/issues/11290 twitter:card summary_large_image og:image https://opengraph.githubassets.com/a6371a2c818e19538aea7b9f6cdcd5461ebc5e4adaccde65773b42003689ae14/matplotlib/matplotlib/issues/11290 og:image:alt The following example In [1]: x = np.array(range(100), dtype='M8[D]') In [2]: ax = plt.subplot(1,1,1) In [3]: y = np.random.random(100) In [4]: ax.bar(x, y) Out[4]: og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username astrofrog 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
URLs of crawlers that visited me.