Title: Plot with dates cannot follow axhline · Issue #17925 · matplotlib/matplotlib · GitHub
Open Graph Title: Plot with dates cannot follow axhline · Issue #17925 · matplotlib/matplotlib
X Title: Plot with dates cannot follow axhline · Issue #17925 · matplotlib/matplotlib
Description: Bug report Bug summary A call to axhline followed by plotting with dates yields an exception. This arises when trying to reproduce #7742. Code for reproduction import matplotlib.pyplot as plt from datetime import datetime fig, ax = plt.s...
Open Graph Description: Bug report Bug summary A call to axhline followed by plotting with dates yields an exception. This arises when trying to reproduce #7742. Code for reproduction import matplotlib.pyplot as plt from ...
X Description: Bug report Bug summary A call to axhline followed by plotting with dates yields an exception. This arises when trying to reproduce #7742. Code for reproduction import matplotlib.pyplot as plt from ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/17925
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Plot with dates cannot follow axhline","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nA call to `axhline` followed by plotting with dates yields an exception.\r\n\r\nThis arises when trying to reproduce #7742.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nfrom datetime import datetime\r\n\r\nfig, ax = plt.subplots()\r\n\r\nax.axhline(1.5)\r\nax.plot([datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)], [1, 2])\r\n\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n```\r\nTypeError Traceback (most recent call last)\r\n\u003cipython-input-5-02e4fc5c74c6\u003e in \u003cmodule\u003e\r\n 5\r\n 6 ax.axhline(1.5)\r\n----\u003e 7 ax.plot([datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)], [1, 2])\r\n\r\n~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)\r\n 1743 lines = [*self._get_lines(*args, data=data, **kwargs)]\r\n 1744 for line in lines:\r\n-\u003e 1745 self.add_line(line)\r\n 1746 self._request_autoscale_view(scalex=scalex, scaley=scaley)\r\n 1747 return lines\r\n\r\n~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_base.py in add_line(self, line)\r\n 1975 line.set_clip_path(self.patch)\r\n 1976\r\n-\u003e 1977 self._update_line_limits(line)\r\n 1978 if not line.get_label():\r\n 1979 line.set_label('_line%d' % len(self.lines))\r\n\r\n~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_base.py in _update_line_limits(self, line)\r\n 1997 Figures out the data limit of the given line, updating self.dataLim.\r\n 1998 \"\"\"\r\n-\u003e 1999 path = line.get_path()\r\n 2000 if path.vertices.size == 0:\r\n 2001 return\r\n\r\n~/work/programs/py/mpl/matplotlib/lib/matplotlib/lines.py in get_path(self)\r\n 1009 \"\"\"\r\n 1010 if self._invalidy or self._invalidx:\r\n-\u003e 1011 self.recache()\r\n 1012 return self._path\r\n 1013\r\n\r\n~/work/programs/py/mpl/matplotlib/lib/matplotlib/lines.py in recache(self, always)\r\n 651 if always or self._invalidx:\r\n 652 xconv = self.convert_xunits(self._xorig)\r\n--\u003e 653 x = _to_unmasked_float_array(xconv).ravel()\r\n 654 else:\r\n 655 x = self._x\r\n\r\n~/work/programs/py/mpl/matplotlib/lib/matplotlib/cbook/__init__.py in _to_unmasked_float_array(x)\r\n 1296 return np.ma.asarray(x, float).filled(np.nan)\r\n 1297 else:\r\n-\u003e 1298 return np.asarray(x, float)\r\n 1299\r\n 1300\r\n~/miniconda3/envs/mpl1/lib/python3.7/site-packages/numpy/core/_asarray.py in asarray(a, dtype, order)\r\n 83\r\n 84 \"\"\"\r\n---\u003e 85 return array(a, dtype, copy=False, order=order)\r\n 86\r\n 87\r\n\r\nTypeError: float() argument must be a string or a number, not 'datetime.datetime'\r\n\r\n```\r\n\r\n**Expected outcome**\r\nA plot, with or without the bug from #7742.\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\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\r\n * Matplotlib version: 3.3.0rc1.post273+gb803891a4b\r\n","author":{"url":"https://github.com/efiring","@type":"Person","name":"efiring"},"datePublished":"2020-07-14T23:55:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/17925/matplotlib/issues/17925"}
| 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:7fee4fd5-c483-87f4-82b5-60fa5592f852 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B964:1480EB:BCC353:FCBD44:6A529C2F |
| html-safe-nonce | 29051271f631f47fe3b9f27785636c96f023ca5d28c9ee0c2809e7ac8a8431cb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTY0OjE0ODBFQjpCQ0MzNTM6RkNCRDQ0OjZBNTI5QzJGIiwidmlzaXRvcl9pZCI6IjkxODA5Mzk1MDQzODUxMzcxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8ff90b1de7f5dd4f9be51f83b9b33bdbf2b5f5b5a49d9b767dc57301e1b1aef2 |
| hovercard-subject-tag | issue:656966201 |
| 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/17925/issue_layout |
| twitter:image | https://opengraph.githubassets.com/16958983b62181d2a51b618cab8de2492facae827922fd9665ab32f20be60a57/matplotlib/matplotlib/issues/17925 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/16958983b62181d2a51b618cab8de2492facae827922fd9665ab32f20be60a57/matplotlib/matplotlib/issues/17925 |
| og:image:alt | Bug report Bug summary A call to axhline followed by plotting with dates yields an exception. This arises when trying to reproduce #7742. Code for reproduction import matplotlib.pyplot as plt from ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | efiring |
| 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 | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width