Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Open
Description
Problem
It should be possible to set the position of a violin plot to be a datetime, but currently this fails:
importdatetimeimportmatplotlib.pyplotaspltfig,ax=plt.subplots()datetimes= [datetime.datetime(2023,2,10),datetime.datetime(2023,5,18),datetime.datetime(2023,6,6)]ax.violin( [ {'coords':datetimes,'vals': [0.1,0.5,0.2],'mean':datetimes[1],'median':datetimes[1],'min':datetimes[0],'max':datetimes[-1],'quantiles':datetimes } ],positions=[datetime.datetime(2020,1,1)])
Traceback (mostrecentcalllast):File"/Users/dstansby/software/mpl/matplotlib/test.py",line11,in<module>ax.violin(File"/Users/dstansby/miniforge3/envs/mpl-dev/lib/python3.12/site-packages/matplotlib/_api/deprecation.py",line453,inwrapperreturnfunc(*args,**kwargs)^^^^^^^^^^^^^^^^^^^^^File"/Users/dstansby/miniforge3/envs/mpl-dev/lib/python3.12/site-packages/matplotlib/axes/_axes.py",line9064,inviolinline_ends= [[-0.25ifsidein ['both','low']else0],^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^TypeError:unsupportedoperandtype(s)for+:'float'and'datetime.datetime'
Proposed solution
No response