Closed
Description
The following code snippet (comment in the dtime = 1
line and this works)
from datetime import datetime
import matplotlib.pyplot as plt
import matplotlib.patches as mpatch
dtime = datetime(2000, 1, 1)
# dtime = 1
fig, ax = plt.subplots()
ax.plot(0, dtime)
arrow = mpatch.FancyArrowPatch((0, dtime), (0.01, dtime))
ax.add_patch(arrow)
fails with
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-99968ca80698> in <module>
10 arrowstyle='-|>', mutation_scale=10,
11 facecolor='k', clip_on=False)
---> 12 ax.add_patch(arrow)
~/github/matplotlib/lib/matplotlib/axes/_base.py in add_patch(self, p)
1965 if p.get_clip_path() is None:
1966 p.set_clip_path(self.patch)
-> 1967 self._update_patch_limits(p)
1968 self.patches.append(p)
1969 p._remove_method = self.patches.remove
~/github/matplotlib/lib/matplotlib/axes/_base.py in _update_patch_limits(self, patch)
1983 ((not patch.get_width()) and (not patch.get_height()))):
1984 return
-> 1985 vertices = patch.get_path().vertices
1986 if vertices.size > 0:
1987 xys = patch.get_patch_transform().transform(vertices)
~/github/matplotlib/lib/matplotlib/patches.py in get_path(self)
4239 in display coordinates.
4240 """
-> 4241 _path, fillable = self.get_path_in_displaycoord()
4242
4243 if np.iterable(fillable):
~/github/matplotlib/lib/matplotlib/patches.py in get_path_in_displaycoord(self)
4254
4255 if self._posA_posB is not None:
-> 4256 posA = self.get_transform().transform_point(self._posA_posB[0])
4257 posB = self.get_transform().transform_point(self._posA_posB[1])
4258 _path = self.get_connectionstyle()(posA, posB,
~/github/matplotlib/lib/matplotlib/transforms.py in transform_point(self, point)
1517 if len(point) != self.input_dims:
1518 raise ValueError("The length of 'point' must be 'self.input_dims'")
-> 1519 return self.transform(np.asarray([point]))[0]
1520
1521 def transform_path(self, path):
~/github/matplotlib/lib/matplotlib/transforms.py in transform(self, values)
1430
1431 # Transform the values
-> 1432 res = self.transform_affine(self.transform_non_affine(values))
1433
1434 # Convert the result back to the shape of the input values.
~/github/matplotlib/lib/matplotlib/transforms.py in transform_affine(self, points)
2416
2417 def transform_affine(self, points):
-> 2418 return self.get_affine().transform(points)
2419 transform_affine.__doc__ = Transform.transform_affine.__doc__
2420
~/github/matplotlib/lib/matplotlib/transforms.py in transform(self, values)
1745
1746 def transform(self, values):
-> 1747 return self.transform_affine(values)
1748 transform.__doc__ = Transform.transform.__doc__
1749
~/github/matplotlib/lib/matplotlib/transforms.py in transform_affine(self, points)
1829 tpoints = affine_transform(points.data, mtx)
1830 return np.ma.MaskedArray(tpoints, mask=np.ma.getmask(points))
-> 1831 return affine_transform(points, mtx)
1832
1833 def transform_point(self, point):
TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'
I'm guessing there needs to be some unit conversion somewhere along the line, that isn't currently happening.