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]: contour levels with units are not converted correctly #25063

Open
@dstansby

Description

@dstansby

Bug summary

When trying to pass levels with unit-ful data to contour, the units are not correctly converted. In the example below I choose 7 contour levels from min(Z) to max(Z), and convert the units from kg to g. This should just change the units, not the locations where contour levels are drawn. The levels array is interpreted without units, and no contours are drawn.

Code for reproduction

importmatplotlib.pyplotaspltimportnumpyasnpimportpintureg=pint.UnitRegistry()ureg.setup_matplotlib()X,Y=np.meshgrid(np.linspace(-3,3,16),np.linspace(-3,3,16))Z= (1-X/2+X**5+Y**3)*np.exp(-X**2-Y**2)Z*=ureg.kglevels=np.linspace(np.min(Z),np.max(Z),7).to(ureg.g)fig,ax=plt.subplots()ax.contour(X,Y,Z,levels=levels)plt.show()

Actual outcome

blank

Expected outcome

correct

Additional information

No response

Operating system

No response

Matplotlib Version

3.7.0.dev1431+g526cb71e20.d20230123

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

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