Description
Bug summary
Matplotlib 3.5.1
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(19680801)
Z = np.random.rand(10, 10)
x = np.arange(0, 10, 1)
y = np.arange(10, 20, 1)
fig, ax = plt.subplots()
qmesh = ax.pcolormesh(x, y, Z)
array_2d = np.random.rand(10,10)
qmesh.set_array(array_2d)
plt.show()
Actual outcome
When I set array to QuadMesh collection and mouse over the image, this error log is produced
Traceback (most recent call last):
File "/home/simons/sdat/lib/python3.9/site-packages/matplotlib/cbook/init.py", line 287, in process
func(*args, **kwargs)
File "/home/simons/sdat/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 3061, in mouse_move
s = self._mouse_event_to_message(event)
File "/home/simons/sdat/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 3051, in _mouse_event_to_message
data = a.get_cursor_data(event)
File "/home/simons/sdat/lib/python3.9/site-packages/matplotlib/collections.py", line 2214, in get_cursor_data
return self.get_array()[ind]
File "/home/simons/sdat/lib/python3.9/site-packages/numpy/ma/core.py", line 3220, in getitem
dout = self.data[indx]
IndexError: index 98 is out of bounds for axis 0 with size 10
Expected outcome
Additional information
This happend only when i set_array to existing QuadMesh.
Operating system
Ubunto 20.04
Matplotlib Version
3.5.1
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
No response