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
pandas is seeing recent failures with the 3.7.0 release when usingset_xlim
with strings representing dates and plotting on the x axis with dates
Code for reproduction
In [1]:importmatplotlib.pyplotaspltIn [2]:dates=np.array(['2000-01-01T00:00:00.000000000','2000-01-02T00:00:00.000000000'],dtype='datetime64[ns]')In [3]:values=np.arange(2)In [4]:_,ax=plt.subplots()In [5]:ax.plot(dates,values)Out[5]: [<matplotlib.lines.Line2Dat0x7fba780ae130>]In [6]:ax.set_xlim("1/1/1999","1/1/2001")Traceback (mostrecentcalllast):File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/axis.py",line1736,inconvert_unitsret=self.converter.convert(x,self.units,self)File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/category.py",line57,inconvertunit.update(values)File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/category.py",line216,inupdate_api.check_isinstance((str,bytes),value=val)File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/_api/__init__.py",line93,incheck_isinstanceraiseTypeError(TypeError:'value'mustbeaninstanceofstrorbytes,notaintTheaboveexceptionwasthedirectcauseofthefollowingexception:Traceback (mostrecentcalllast):File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/cbook/__init__.py",line304,inprocessfunc(*args,**kwargs)File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/axes/_base.py",line2455,in_unit_change_handlerline.recache_always()File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/lines.py",line652,inrecache_alwaysself.recache(always=True)File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/lines.py",line656,inrecachexconv=self.convert_xunits(self._xorig)File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/artist.py",line281,inconvert_xunitsreturnax.xaxis.convert_units(x)File"/Users/matthewroeschke/opt/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/matplotlib/axis.py",line1738,inconvert_unitsraisemunits.ConversionError('Failed to convert value(s) to axis 'matplotlib.units.ConversionError:Failedtoconvertvalue(s)toaxisunits:array(['2000-01-01T00:00:00.000000000','2000-01-02T00:00:00.000000000'],dtype='datetime64[ns]')Out[6]: (0.0,1.0)In [7]:importmatplotlib;matplotlib.__version__Out[7]:'3.7.0'
Actual outcome
(The iPython example above shows the outcome)
Expected outcome
No exception traceback.
Additional information
This appeared to work in the 3.6.x series. I could no find documentation regarding this functionality not being supported
Operating system
No response
Matplotlib Version
3.7.0
Matplotlib Backend
No response
Python version
3.8
Jupyter version
No response
Installation
conda