# How to Wrap the Points of a 3D Clustering Plot?

I am doing clustering and have a plot as below:-

GaussianRandomData[n_Integer,p_,sigma_]:=Table[p+{Re[#],Im[#],RandomReal[NormalDistribution[0,sigma]]}&[RandomReal[NormalDistribution[0,sigma]] E^(I RandomReal[{0,2 π}])],{n}];
datapairs=BlockRandom[SeedRandom[1234];Join[GaussianRandomData[100,{15,10,0},.3],GaussianRandomData[100,{12,13,0},.2],GaussianRandomData[100,{10,11,0},.4],GaussianRandomData[100,{12,13,0},0.1]]];
data1=FindClusters[datapairs];
ListPointPlot3D[data1]


Is it possible to wrap the points up by some surfaces (either transparent or not; either just coloring at the boundaries or filled up; either elliptic or irregular)? That would be similar to the following 2D case:-

If being wrapped by surfaces is not possible, is it possible to just add lines linking the points of the same cluster?

Many thanks!

• Look at ConvexHullMesh – OkkesDulgerci Jun 13 '18 at 13:58

 Show[ListPointPlot3D[data1, PlotTheme -> "Business",
PlotStyle -> {AbsolutePointSize[3]}],
Table[{HighlightMesh[ConvexHullMesh[data1[[i]]],
Style[2, ColorData[97, i], Opacity[0.2]]]}, {i, 3}]]


• Thanks for reply. Is there a way to change the surfaces into 3 different colors? I think the change should be at Style[2, Opacity[0.5]]? – H42 Jun 13 '18 at 14:30
• Style[2, Orange, Opacity[0.5]] – OkkesDulgerci Jun 13 '18 at 14:37
• Is this what you are looking for or what you want is smallest ball or ellipsoid that contain all points? – OkkesDulgerci Jun 13 '18 at 14:39
• I just want a clear illustration to show separated clusters. In my real data, there are several thousand points and there are around 20 to 100 clusters overlapping each other. It is likely that I will keep refreshing the plot with different parameters to analyze the data, so I hope the selected method would be more computationally efficient (or not too worse) than the other methods. – H42 Jun 13 '18 at 14:52
• For my real case in which the clusters overlapping each other, I noted that ConvexHullMesh is a better solution than BoundingRegion[#,"FastEllipsoid"]&, since the ellipsoid would be much larger than the hull, making the graph less illustrative since the large ellipsoids overlap each other too much. – H42 Jun 13 '18 at 15:42

Yu could use BoundingRegion with the "FastEllipsoid" as second argument:

Graphics3D[{
Transpose[{
ColorData[97] /@ Range[3],
Point /@ data1
}],
Opacity[0.25],
Transpose[{
ColorData[97] /@ Range[3],
BoundingRegion[#, "FastEllipsoid"] & /@ data1
}]
},
Lighting -> "Neutral"
]


See also the documenttion of BoundingRegion for further bounding shapes.