Here is a code I tried:
from scipy.spatial import ConvexHull
points = np.random.rand(30, 2) # 30 random points in 2-D
hull = ConvexHull(points)
import matplotlib.pyplot as plt
%matplotlib inline
corners=[]
for simplex in hull.simplices:
corners+=list(simplex)
plt.fill(points[corners, 0], points[corners, 1], 'k',alpha=0.3)
The only plot I can get is: Convex Hull of random set of points in matplotlib As you can see it is filled partly.
But I'd like all the area within this polygon should be filled.
What are the ways of doing it?
I appreciate any your advice!
Upd: An Answer!!!
Actually I've just found an answer. It was on the official site of SciPy:
We could also have directly used the vertices of the hull, which for 2-D are guaranteed to be in counterclockwise order
So to do what I want I just needed to use:
plt.fill(points[hull.vertices,0], points[hull.vertices,1], 'k', alpha=0.3)
instead of last 4 lines of my upper code.
May be this question/answer will help anyone else.