Reputation: 965
Following array:
p = np.array([[ 0, 0],
[ 9, 0],
[18, 0],
[27, 0],
[36, 0],
[45, 0],
[54, 0],
[63, 0],
[72, 0],
[ 0, 9],
[ 9, 9],
[18, 9],
[27, 9],
[36, 9],
[45, 9],
[54, 9],
[ 0, 18],
[ 9, 18],
[18, 18],
[27, 18],
[36, 18],
[ 0, 27],
[ 9, 27],
[18, 27],
[ 0, 36]])
When I try to run the example from here https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.ConvexHull.html
from scipy.spatial import ConvexHull
import matplotlib.pyplot as plt
plt.plot(p[:,0], p[:,1], 'o')
for simplex in hull.simplices:
plt.plot(points[simplex, 0], points[simplex, 1], 'k-')
I get:
I don't see the convex hull. Anyone knows why?
Upvotes: 1
Views: 116
Reputation: 5000
With few modifications on your code, this should work:
from scipy.spatial import ConvexHull
import matplotlib.pyplot as plt
plt.plot(p[:,0], p[:,1], 'o')
hull = ConvexHull(p)
for simplex in hull.simplices:
plt.plot(p[simplex, 0], p[simplex, 1], 'k-')
Upvotes: 1