Description
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
import matplotlib
import numpy as np
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
fig, 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).
Expected outcome
0.0 should be at the bottom of the page and the window should retain its original size:
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])
assert im.format_cursor_data(data) == '[0]'
should be
data = np.ma.masked_array(0, mask=[False])
assert im.format_cursor_data(data) == '[0]'
And this causes im.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