How to plot 3D trajectory behind a surface?

2020-05-05 22:16发布

问题:

I'm trying to plot the trajectory of a photon orbiting a black hole. I'd like the photon to go behind the black hole and then in front of it (stable circular orbit). However I can't plot that, my photon is either in the foreground or in the background.

I've tried using zorder but it didn't work

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
ax.set_aspect('equal')

# black surface
u = np.linspace(0, 2*np.pi, 100)
v = np.linspace(0, 2*np.pi, 100)

x = rs * np.outer(np.cos(u), np.sin(v))
y = rs * np.outer(np.sin(u), np.sin(v))
z = rs * np.outer(np.ones(np.size(u)), np.cos(v))

# plot black sphere
ax.plot_surface(x, y, z, rstride=4, cstride=4, color='k', zorder=6)

# plot trajectories (photons)
ax.plot(X0, Y0, Z0, 'r', zorder=6)
ax.plot(X1, Y1, Z1, 'b', zorder=5)
ax.plot(X2, Y2, Z2, 'g', zorder=4)
ax.plot(X3, Y3, Z3, 'fuchsia', zorder=3)
ax.plot(X4, Y4, Z4, 'turquoise', zorder=2)


plt.show()

I'd like to have a sphere with photons orbiting it. I'd like to see that the surface is a 3D sphere and not a circle, that is: I'd like the photons to go behind the surface when actually behind and in front of it when actually in front. Can anyone please help me?