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]: Plotting numpy.array of dtype float32 with pyplot.imshow and specified colors.LogNorm produces wrong colors #28731

Closed as not planned
Milestone
@faressc

Description

@faressc

Bug summary

Plotting an equal numpy.array of dtype float64 and float32 with pyplot.imshow and a defined colors.LogNorm as norm will produce different colors in the resulting image.

Code for reproduction

importmatplotlib.pyplotaspltimportmatplotlib.colorsascolorsimportnumpyasnpnorm=colors.LogNorm(vmin=1e-10,vmax=1)test_numpy=np.array([[1e-4]])test_numpy_32=np.array([[1e-4]],dtype=np.float32)fortestin [test_numpy,test_numpy_32]:plt.imshow(test,norm=norm)plt.title(f"numpy array of dtype:{test.dtype}")plt.colorbar()plt.show()

Actual outcome

The resulting plot for the dtype float64 numpy.array looks like this:

float64

and the plot for the dtype float32 numpy.array looks like this:

float32

Expected outcome

I would expect both outputs to have the same color.

Additional information

No response

Operating system

Arch

Matplotlib Version

3.9.1.post1

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

Python 3.12.4

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp