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

Allow use of unitful data in images #19476

Open
@dstansby

Description

@dstansby

Problem

Often the data stored in images can have physical values associated with them. It would therefore be good if there was support for using the unit machinery to allow images to have units.

Proposed Solution

Here's a short example that should work fine using units, but which currently fails. The use of datetime is a bit contrived, but I chose it to avoid a third party package. For a more realistic real-world example seeastropy/astropy#11306.

fromdatetimeimportdatetimeimportmatplotlib.colorsasmcolorimportmatplotlib.pyplotaspltdata= [[datetime.now(),datetime.now()],        [datetime.now(),datetime.now()]]fig,ax=plt.subplots()im=ax.imshow(data,norm=mcolor.LogNorm())fig.colorbar(im)plt.show()

This fails in

File"/Users/dstansby/github/matplotlib/lib/matplotlib/axes/_axes.py",line5586,inimshowim.set_data(X)File"/Users/dstansby/github/matplotlib/lib/matplotlib/image.py",line700,inset_dataraiseTypeError("Image data of dtype {} cannot be converted to "TypeError:Imagedataofdtypeobjectcannotbeconvertedtofloat

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