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]: Units behavior ofstreamplot #27500

Open
@ksunden

Description

@ksunden

Bug summary

As seen in#27489streamplot does not allow passing unitful data as x/y

Code for reproduction

fig,ax=plt.subplots()np.random.seed(19680801)limit_value=30date_array=np.array(        [datetime.datetime(2023,12,n)forninrange(1,limit_value)]    ,dtype=np.datetime64)#date_array_converted = mpl.dates.date2num(date_array)X,Y=np.meshgrid(date_array,date_array)U=np.random.rand(limit_value-1,limit_value-1)V=np.random.rand(limit_value-1,limit_value-1)ax.streamplot(X,Y,U,V)

Actual outcome

Traceback (mostrecentcalllast):File"/home/kyle/play/gh27487.py",line22,in<module>ax.streamplot(X,Y,U,V)File"/home/kyle/src/scipy/matplotlib/lib/matplotlib/__init__.py",line1472,ininnerreturnfunc(^^^^^File"/home/kyle/src/scipy/matplotlib/lib/matplotlib/streamplot.py",line91,instreamplotgrid=Grid(x,y)^^^^^^^^^^File"/home/kyle/src/scipy/matplotlib/lib/matplotlib/streamplot.py",line330,in__init__ifnotnp.allclose(x_row,x):^^^^^^^^^^^^^^^^^^^^^File"/home/kyle/.pyenv/versions/edge/lib/python3.11/site-packages/numpy/core/numeric.py",line2241,inallcloseres=all(isclose(a,b,rtol=rtol,atol=atol,equal_nan=equal_nan))^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/home/kyle/.pyenv/versions/edge/lib/python3.11/site-packages/numpy/core/numeric.py",line2345,inisclosedt=multiarray.result_type(y,1.)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^numpy.exceptions.DTypePromotionError:TheDType<class'numpy._FloatAbstractDType'>couldnotbepromotedby<class'numpy.dtypes.DateTime64DType'>.ThismeansthatnocommonDTypeexistsforthegiveninputs.Forexampletheycannotbestoredinasinglearrayunlessthedtypeis`object`.ThefulllistofDTypesis: (<class 'numpy.dtypes.DateTime64DType'>, <class 'numpy._FloatAbstractDType'>)

Expected outcome

Units can be passed as at least X/Ya (I could see requiring them to be thesame units... or even saying "this type of plotshouldn't support units", but would want to be explicit about that.

I do wonder a bit aboutU/V and whether they should be specified indelta units or not?quiver can treat them as independent values or as delta values, I believe, but don't see such a distinction on stream lines.

Additional information

May be as easy as calling_process_unit_info on the inputs, I think.

Operating system

No response

Matplotlib Version

3.9.0.dev821+gfa6be74127 (~main at time of reporting)

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

git checkout

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