Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Bug summary
pyplot raises an error when a list of dates starts with None.
Code for reproduction
fromdatetimeimport*frommatplotlibimportpyplotasplty= [6,2,8,3,1,8,5,3,0,7]x= [date.today()+timedelta(days=i)foriinrange(10)]x[5]=Nonex[-1]=Noneplt.plot(x,y)# worksplt.show()x[0]=Noneplt.plot(x,y)# TypeErrorplt.show()
Actual outcome
Traceback (most recent call last): File "pyplot_test.py", line 17, in <module> plt.plot(x, y) File "<python_path>\lib\site-packages\matplotlib\pyplot.py", line 2769, in plot return gca().plot( File "<python_path>\lib\site-packages\matplotlib\axes\_axes.py", line 1634, in plot self.add_line(line) File "<python_path>\lib\site-packages\matplotlib\axes\_base.py", line 2288, in add_line self._update_line_limits(line) File "<python_path>\lib\site-packages\matplotlib\axes\_base.py", line 2311, in _update_line_limits path = line.get_path() File "<python_path>\lib\site-packages\matplotlib\lines.py", line 999, in get_path self.recache() File "<python_path>\lib\site-packages\matplotlib\lines.py", line 652, in recache x = _to_unmasked_float_array(xconv).ravel() File "<python_path>\lib\site-packages\matplotlib\cbook\__init__.py", line 1298, in _to_unmasked_float_array return np.asarray(x, float) File "<python_path>\lib\site-packages\numpy\core\_asarray.py", line 85, in asarray return array(a, dtype, copy=False, order=order)TypeError: float() argument must be a string or a number, not 'datetime.date'
Expected outcome
plot data starting at index 1.
Additional information
No response
Operating system
windows 10
Matplotlib Version
3.5.2
Matplotlib Backend
TkAgg
Python version
3.8.2
Jupyter version
No response
Installation
pip