<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">A call to <code class="notranslate">axhline</code> followed by plotting with dates yields an exception.</p>
<p dir="auto">This arises when trying to reproduce <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="198766370" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/7742" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/7742/hovercard" href="https://github.com/matplotlib/matplotlib/issues/7742">#7742</a>.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
from datetime import datetime

fig, ax = plt.subplots()

ax.axhline(1.5)
ax.plot([datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)], [1, 2])
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">from</span> <span class="pl-s1">datetime</span> <span class="pl-k">import</span> <span class="pl-s1">datetime</span>

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>()

<span class="pl-s1">ax</span>.<span class="pl-en">axhline</span>(<span class="pl-c1">1.5</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">plot</span>([<span class="pl-en">datetime</span>(<span class="pl-c1">2016</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>), <span class="pl-en">datetime</span>(<span class="pl-c1">2016</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>)], [<span class="pl-c1">1</span>, <span class="pl-c1">2</span>])</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError                                 Traceback (most recent call last)
&lt;ipython-input-5-02e4fc5c74c6&gt; in &lt;module&gt;
      5
      6 ax.axhline(1.5)
----&gt; 7 ax.plot([datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)], [1, 2])

~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
   1743         lines = [*self._get_lines(*args, data=data, **kwargs)]
   1744         for line in lines:
-&gt; 1745             self.add_line(line)
   1746         self._request_autoscale_view(scalex=scalex, scaley=scaley)
   1747         return lines

~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_base.py in add_line(self, line)
   1975             line.set_clip_path(self.patch)
   1976
-&gt; 1977         self._update_line_limits(line)
   1978         if not line.get_label():
   1979             line.set_label('_line%d' % len(self.lines))

~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_base.py in _update_line_limits(self, line)
   1997         Figures out the data limit of the given line, updating self.dataLim.
   1998         &quot;&quot;&quot;
-&gt; 1999         path = line.get_path()
   2000         if path.vertices.size == 0:
   2001             return

~/work/programs/py/mpl/matplotlib/lib/matplotlib/lines.py in get_path(self)
   1009         &quot;&quot;&quot;
   1010         if self._invalidy or self._invalidx:
-&gt; 1011             self.recache()
   1012         return self._path
   1013

~/work/programs/py/mpl/matplotlib/lib/matplotlib/lines.py in recache(self, always)
    651         if always or self._invalidx:
    652             xconv = self.convert_xunits(self._xorig)
--&gt; 653             x = _to_unmasked_float_array(xconv).ravel()
    654         else:
    655             x = self._x

~/work/programs/py/mpl/matplotlib/lib/matplotlib/cbook/__init__.py in _to_unmasked_float_array(x)
   1296         return np.ma.asarray(x, float).filled(np.nan)
   1297     else:
-&gt; 1298         return np.asarray(x, float)
   1299
   1300
~/miniconda3/envs/mpl1/lib/python3.7/site-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
     83
     84     &quot;&quot;&quot;
---&gt; 85     return array(a, dtype, copy=False, order=order)
     86
     87

TypeError: float() argument must be a string or a number, not 'datetime.datetime'
"><pre class="notranslate"><code class="notranslate">TypeError                                 Traceback (most recent call last)
&lt;ipython-input-5-02e4fc5c74c6&gt; in &lt;module&gt;
      5
      6 ax.axhline(1.5)
----&gt; 7 ax.plot([datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)], [1, 2])

~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
   1743         lines = [*self._get_lines(*args, data=data, **kwargs)]
   1744         for line in lines:
-&gt; 1745             self.add_line(line)
   1746         self._request_autoscale_view(scalex=scalex, scaley=scaley)
   1747         return lines

~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_base.py in add_line(self, line)
   1975             line.set_clip_path(self.patch)
   1976
-&gt; 1977         self._update_line_limits(line)
   1978         if not line.get_label():
   1979             line.set_label('_line%d' % len(self.lines))

~/work/programs/py/mpl/matplotlib/lib/matplotlib/axes/_base.py in _update_line_limits(self, line)
   1997         Figures out the data limit of the given line, updating self.dataLim.
   1998         """
-&gt; 1999         path = line.get_path()
   2000         if path.vertices.size == 0:
   2001             return

~/work/programs/py/mpl/matplotlib/lib/matplotlib/lines.py in get_path(self)
   1009         """
   1010         if self._invalidy or self._invalidx:
-&gt; 1011             self.recache()
   1012         return self._path
   1013

~/work/programs/py/mpl/matplotlib/lib/matplotlib/lines.py in recache(self, always)
    651         if always or self._invalidx:
    652             xconv = self.convert_xunits(self._xorig)
--&gt; 653             x = _to_unmasked_float_array(xconv).ravel()
    654         else:
    655             x = self._x

~/work/programs/py/mpl/matplotlib/lib/matplotlib/cbook/__init__.py in _to_unmasked_float_array(x)
   1296         return np.ma.asarray(x, float).filled(np.nan)
   1297     else:
-&gt; 1298         return np.asarray(x, float)
   1299
   1300
~/miniconda3/envs/mpl1/lib/python3.7/site-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
     83
     84     """
---&gt; 85     return array(a, dtype, copy=False, order=order)
     86
     87

TypeError: float() argument must be a string or a number, not 'datetime.datetime'

</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong><br>
A plot, with or without the bug from <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="198766370" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/7742" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/7742/hovercard" href="https://github.com/matplotlib/matplotlib/issues/7742">#7742</a>.</p>


<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Matplotlib version: 3.3.0rc1.post273+gb803891a4b</li>
</ul>
<h3 dir="auto">Bug report</h3>
<p dir="auto">On master branch, plotting datetimes appears to be broken. This error bisects to <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/matplotlib/matplotlib/commit/a793bde0571709597d7434c4bdbf6e3ad5cd183b/hovercard" href="https://github.com/matplotlib/matplotlib/commit/a793bde0571709597d7434c4bdbf6e3ad5cd183b"><tt>a793bde</tt></a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="593692299" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/17022" data-hovercard-type="pull_request" data-hovercard-url="/matplotlib/matplotlib/pull/17022/hovercard" href="https://github.com/matplotlib/matplotlib/pull/17022">#17022</a></p>

<p dir="auto"><strong>Code for reproduction</strong></p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
from datetime import datetime

fig, ax = plt.subplots()
ax.plot(datetime.now(), 1)
plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">from</span> <span class="pl-s1">datetime</span> <span class="pl-k">import</span> <span class="pl-s1">datetime</span>

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>()
<span class="pl-s1">ax</span>.<span class="pl-en">plot</span>(<span class="pl-s1">datetime</span>.<span class="pl-en">now</span>(), <span class="pl-c1">1</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  File &quot;test.py&quot;, line 5, in &lt;module&gt;
    ax.plot(datetime.now(), 1)
  File &quot;/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_axes.py&quot;, line 1745, in plot
    self.add_line(line)
  File &quot;/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_base.py&quot;, line 1977, in add_line
    self._update_line_limits(line)
  File &quot;/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_base.py&quot;, line 1999, in _update_line_limits
    path = line.get_path()
  File &quot;/Users/dstansby/github/matplotlib/lib/matplotlib/lines.py&quot;, line 1011, in get_path
    self.recache()
  File &quot;/Users/dstansby/github/matplotlib/lib/matplotlib/lines.py&quot;, line 653, in recache
    x = _to_unmasked_float_array(xconv).ravel()
  File &quot;/Users/dstansby/github/matplotlib/lib/matplotlib/cbook/__init__.py&quot;, line 1298, in _to_unmasked_float_array
    return np.asarray(x, float)
  File &quot;/Users/dstansby/miniconda3/envs/dev/lib/python3.8/site-packages/numpy/core/_asarray.py&quot;, line 83, in asarray
    return array(a, dtype, copy=False, order=order)
TypeError: float() argument must be a string or a number, not 'datetime.datetime'"><pre class="notranslate"><code class="notranslate">  File "test.py", line 5, in &lt;module&gt;
    ax.plot(datetime.now(), 1)
  File "/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_axes.py", line 1745, in plot
    self.add_line(line)
  File "/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_base.py", line 1977, in add_line
    self._update_line_limits(line)
  File "/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_base.py", line 1999, in _update_line_limits
    path = line.get_path()
  File "/Users/dstansby/github/matplotlib/lib/matplotlib/lines.py", line 1011, in get_path
    self.recache()
  File "/Users/dstansby/github/matplotlib/lib/matplotlib/lines.py", line 653, in recache
    x = _to_unmasked_float_array(xconv).ravel()
  File "/Users/dstansby/github/matplotlib/lib/matplotlib/cbook/__init__.py", line 1298, in _to_unmasked_float_array
    return np.asarray(x, float)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.8/site-packages/numpy/core/_asarray.py", line 83, in asarray
    return array(a, dtype, copy=False, order=order)
TypeError: float() argument must be a string or a number, not 'datetime.datetime'
</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>


<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system:</li>
<li>Matplotlib version:</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>):</li>
<li>Python version:</li>
<li>Jupyter version (if applicable):</li>
<li>Other libraries:</li>
</ul>