Hi,
I have the following situation. I have been following the example to create a 3d surface, as explained here:
http://matplotlib.sourceforge.net/examples/mplot3d/surface3d_demo2.html
and I have altered the code slightly to plot a straight red line from the center outside of the sphere (see code at the end of this email). As one can see, the whole line is visible always, no matter how the sphere is turned. Is there a way to ‘hide’ those parts of the red line, which are ‘behind’ the blue surface? Like you stick a pencil into an apple and turn the apple, so you can see parts of the pencil, depending on how the apple is rotated (except the part of the pencil inside the apple)?
If someone can help me with that problem that would be great.
Thanks
Alex
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
#ax = fig.add_subplot(111, projection=‘3d’)
ax = Axes3D(fig)
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot([0,15],[0.0,0.0],‘r’, lw=4)
ax.plot_surface(x, y, z, rstride=4, cstride=4, color=‘b’)
plt.show()