Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: Data with units not supported on 3d plots #22207

Open
@TD22057

Description

@TD22057

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp