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

index in pick_event invalid and inconsistent for mplot3d scatter plot (z ordering?) #19735

Open
@saasbk

Description

@saasbk

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:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp