Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Description
Bug summary
Attempting to make a basic x,y,z plot on a 3d axes with units doesn't work because the conversion to numpy array fails. I assume this is because the data is never passed through the unit conversion API.
Code for reproduction
importmatplotlib.pyplotaspltimportmpl_toolkits.mplot3dimportmatplotlib.testing.jpl_unitsasunitsunits.register()x= [i*units.kmforiinrange(10)]y= [2*i*units.kmforiinrange(10)]z= [3*i*units.kmforiinrange(10)]fig=plt.figure()ax=fig.add_subplot(projection="3d")ax.plot(x,y,z)plt.show()
Actual outcome
File "/home/trd/t.py", line 12, in <module> ax.plot(x, y, z) File "/group/monte/tools/rhel7_64/core-12/lib/python3.9/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1500, in plot self.auto_scale_xyz(xs, ys, zs, had_data) File "/group/monte/tools/rhel7_64/core-12/lib/python3.9/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 648, in auto_scale_xyz self.xy_dataLim.update_from_data_xy( File "/group/monte/tools/rhel7_64/core-12/lib/python3.9/site-packages/matplotlib/transforms.py", line 967, in update_from_data_xy path = Path(xy) File "/group/monte/tools/rhel7_64/core-12/lib/python3.9/site-packages/matplotlib/path.py", line 129, in __init__ vertices = _to_unmasked_float_array(vertices) File "/group/monte/tools/rhel7_64/core-12/lib/python3.9/site-packages/matplotlib/cbook/__init__.py", line 1298, in _to_unmasked_float_array return np.asarray(x, float) File "/group/monte/tools/rhel7_64/core-12/lib/python3.9/site-packages/numpy/core/_asarray.py", line 102, in asarray return array(a, dtype, copy=False, order=order)TypeError: float() argument must be a string or a number, not 'UnitDbl'
Expected outcome
A 3d plot.
Additional information
No response
Operating system
No response
Matplotlib Version
3.5.0
Matplotlib Backend
QtAgg
Python version
3.9.7
Jupyter version
No response
Installation
No response