7
$\begingroup$

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]

The plot of virus outbreak

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:-

enter image description here

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

Many thanks!

$\endgroup$
  • $\begingroup$ Look at ConvexHullMesh $\endgroup$ – OkkesDulgerci Jun 13 '18 at 13:58
8
$\begingroup$
 Show[ListPointPlot3D[data1, PlotTheme -> "Business", 
  PlotStyle -> {AbsolutePointSize[3]}], 
 Table[{HighlightMesh[ConvexHullMesh[data1[[i]]], 
    Style[2, ColorData[97, i], Opacity[0.2]]]}, {i, 3}]]

enter image description here

$\endgroup$
  • $\begingroup$ 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]]? $\endgroup$ – H42 Jun 13 '18 at 14:30
  • $\begingroup$ Style[2, Orange, Opacity[0.5]] $\endgroup$ – OkkesDulgerci Jun 13 '18 at 14:37
  • $\begingroup$ Is this what you are looking for or what you want is smallest ball or ellipsoid that contain all points? $\endgroup$ – OkkesDulgerci Jun 13 '18 at 14:39
  • $\begingroup$ 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. $\endgroup$ – H42 Jun 13 '18 at 14:52
  • 1
    $\begingroup$ 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. $\endgroup$ – H42 Jun 13 '18 at 15:42
9
$\begingroup$

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"
 ]

enter image description here

See also the documenttion of BoundingRegion for further bounding shapes.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.