I have a numpy array vertices
of shape (N,3) containing the N vertices of a spherical polygon in 3D, i.e. all these points lie on the surface of a sphere. The center and radius of the sphere is known (take the unit sphere for example). I would like to plot the spherical polygon bounded by these vertices. (Mathematically speaking, I want to plot the spherically convex hull generated by these vertices).
How can I do that using matplotlib
? I tried Poly3DCollection
, but this only plots the Euclidean polygon. I managed to plot the entire unit sphere using plot_surface
like this:
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = np.outer(np.cos(u), np.sin(v))
y = np.outer(np.sin(u), np.sin(v))
z = np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z, rstride=5, cstride=5, color='y', alpha=0.1)
I guess one could manually calculate what points to remove from x, y, z
and then still use plot_surface
in order to plot the polygon. Would this be the correct way to use matplotlib
or does it have another module, which I could use directly?
In case there is no convenient way to do this in matplotlib
, can you recommend any other library, which does that?