Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
The index returned in the pick_event (event.ind) does not correspond to the index of the source data.
It also changes depending on the view onto the data.
The example contains two points.
When you click on a point, the event.ind is printed out.
The one at (0,0,0) should have index 0, the other index 1.
Rotate the plot so that the second point is further behind (semi transparent). Now it has index 0.
Rotate the plot so that the second point is further in front (full opacity). Now it has index 1.
Code for reproduction
`
importnumpyasnpimportmatplotlibimportmatplotlib.pyplotaspltfrommpl_toolkits.mplot3dimportAxes3Dif__name__=="__main__":fig=plt.figure(constrained_layout=True,figsize=(6,6))ax=fig.add_subplot(111,projection='3d')num_points=2data=np.zeros([num_points,3])data[:,0]=np.linspace(1,0,num_points)print(data)path_collection=ax.scatter(xs=data[:,0],ys=data[:,1],zs=data[:,2],picker=True)ax.set_xlabel("x")ax.set_ylabel("y")ax.set_zlabel("z")ax.set_xlim(-1,1)ax.set_ylim(-1,1)ax.set_zlim(-1,1)defonpick(event):print(event.ind)fig.canvas.mpl_connect('pick_event',onpick)plt.show()`
Actual outcome
The example contains two points.
When you click on a point, the event.ind is printed out.
The one at (0,0,0) should have index 0, the other index 1.
Rotate the plot so that the second point is further behind (semi transparent). Now it has index 0.
Rotate the plot so that the second point is further in front (full opacity). Now it has index 1.
Expected outcome
The returned event.ind should not depend on view.
For the point in the centre it should always return 0, for the point to the right, it should always return 1.
Matplotlib version
- Operating system: macOS Catalina; 10.15.4
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): '3.3.4' - Matplotlib backend (
print(matplotlib.get_backend())
): 'MacOSX' - Python version: Python 3.6.9
- Jupyter version (if applicable):
- Other libraries: