Reputation: 20355
I wish to have two sectors (one in blue color, the other in black pencil) in 3D, and they share the same vertex on the plane. The black pencil one lies on the plane, whereas the blue one is theta above the plane.
The effect I am expecting is shown as the picture here.
It would be nice if I can also mark the three angles out.
What I have tried:
from matplotlib.patches import Wedge
from matplotlib.collections import PatchCollection
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
ax = Axes3D(fig)
patches = []
patches.append(Wedge((.8,.3), .2, 0, 45))
p = PatchCollection(patches)
ax.add_collection3d(p)
plt.show()
Upvotes: 1
Views: 673
Reputation: 12234
The issue you will ultimately run into is that matplotlib 3d is only a projection of shapes, and does not try to render an object in 3d.
It is possible and well demonstrated in this post but I advise you run the code from @Lileth's answer to see where the projection limits you.
Alternatives exist such as:
Mayavi where you could use mesh()
, defining two arrays for the shapes.
If you are familiar with Latex, Tikz is capable of producing fantastic 3d plots, but the learning curve is quite steep -- in general it is best to choose the example closest to what you want and hack rather than go from scratch.
Upvotes: 2