I saw this post about how to plot a convex hull: Calculating and displaying a ConvexHull
And tried to mimic it for my needs.
The problem is that it seems that this only works for integer typed tuples, and not floating point tuples. So I have this function that gets 2D points (float tuples), and a plot, and I wish that it will return the updated plot (with the convex hull painted) and the hull points:
def get_cp(cluster, plt):
hull = ConvexHull(cluster)
# plt.plot(cluster[:, 0], cluster[:, 1], '.', color='k')
for simplex in hull.simplices:
plt.plot(cluster[simplex, 0], cluster[simplex, 1], 'c')
plt.plot(cluster[hull.vertices, 0], cluster[hull.vertices, 1], 'o', mec='r', color='none', lw=1, markersize=10)
return hull.simplices, plt
Can anyone please assist?