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]: format_image_data on an image of only zeros produces a large number of zeros #28648

Closed
@trygvrad

Description

@trygvrad

Bug summary

If you use imshow, and then mouseover the image, the value is listed at the bottom of the plot.
However, if the image contains only zeros, the result is a comical number of zeros.

Code for reproduction

importmatplotlibimportnumpyasnpmatplotlib.use('TkAgg')importmatplotlib.pyplotaspltfig,ax=plt.subplots()im=ax.imshow(np.zeros((4,4)))fig.show()

Actual outcome

When you mouse-over the image it shows a large number of zeros (see bottom of image).
image

Expected outcome

0.0 should be at the bottom of the page and the window should retain its original size:
image

Additional information

test_image.py→test_image_cursor_formatting() should test this perscise functionality, but there is a bug in this test where

data=np.ma.masked_array([0],mask=[False])assertim.format_cursor_data(data)=='[0]'

should be

data=np.ma.masked_array(0,mask=[False])assertim.format_cursor_data(data)=='[0]'

And this causesim.format_cursor_data to fallback and '0' is returned.
This test should be updated as part of a PR to fix this bug.

Operating system

No response

Matplotlib Version

matplotlib_dev, 3.8.2

Matplotlib Backend

TkAgg

Python version

No response

Jupyter version

No response

Installation

git checkout

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp