You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I would like to know is it could be possible or not to support any subclass inherited from datetime natively (using issubclass() for example)? I tried to dig into the matplotlib source code but this is too complex for me.
The main use-case is for users of alternative datetime libraries like Pendulum or Arrow.
Traceback (most recent call last):
File "C:\Users\delgan\Desktop\test.py", line 11, in <module>
ax.plot(datetimes, values)
File "C:\Users\delgan\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\__init__.py", line 1710, in inner
return func(ax, *args, **kwargs)
File "C:\Users\delgan\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\axes\_axes.py", line 1438, in plot
self.add_line(line)
File "C:\Users\delgan\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\axes\_base.py", line 1759, in add_line
self._update_line_limits(line)
File "C:\Users\delgan\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\axes\_base.py", line 1781, in _update_line_limits
path = line.get_path()
File "C:\Users\delgan\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\lines.py", line 951, in get_path
self.recache()
File "C:\Users\delgan\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\lines.py", line 652, in recache
x = _to_unmasked_float_array(xconv).ravel()
File "C:\Users\delgan\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\cbook\__init__.py", line 2008, in _to_unmasked_float_array
return np.asarray(x, float)
File "C:\Users\delgan\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\numeric.py", line 531, in asarray
return array(a, dtype, copy=False, order=order)
TypeError: float() argument must be a string or a number, not 'MyDatetime'
Expected outcome
There should be no error, and the graph should be plotted as if the dates was proper datetime objects.
Matplotlib version
Operating system: WSL
Matplotlib version: 2.1.0
Matplotlib backen: TkAgg
Python version: 3.6.4
The text was updated successfully, but these errors were encountered:
Not the way units work right now. It uses a lookup table in units.py with the class types as keys, so I'm not sure there is any way to make that check parent classes as well.
Hello!
Bug summary
While trying to use
matplotlib
with custom subclass ofdatetime
objects as x-values, aTypeError
is raised.It seems to exist a workaround using
matplotlib.units
: https://stackoverflow.com/a/10239347/2291710However, I would like to know is it could be possible or not to support any subclass inherited from
datetime
natively (usingissubclass()
for example)? I tried to dig into thematplotlib
source code but this is too complex for me.The main use-case is for users of alternative datetime libraries like
Pendulum
orArrow
.Code for reproduction
Actual outcome
Expected outcome
There should be no error, and the graph should be plotted as if the dates was proper
datetime
objects.Matplotlib version
The text was updated successfully, but these errors were encountered: