I have a lot of points' coordinates. I drew them on a 2d plot with ListPlot
, and the points cover an area. Then I need to get the region that cover these points. Is there a way to do that? Thanks.
3 Answers
$\begingroup$
$\endgroup$
I'm pretty sure that you are asking about convex region. Without this statement one can draw very weird region:
SeedRandom[1];
pts = RandomReal[{-1, 1}, {50, 2}];
Show[Graphics@{LightBlue, EdgeForm@Lighter@Blue,
Polygon@Deintersect[pts]}, ListPlot[pts]]
Deintersect
is defined here.
$\begingroup$
$\endgroup$
pts = RandomReal[{-1, 1}, {50, 2}];
Show[ConvexHullMesh[pts], ListPlot[pts]]
For earlier versions see ConvexHull
.
$\begingroup$
$\endgroup$
Yet another area defined by the list of points:
SeedRandom[1];
pts = RandomReal[{-1, 1}, {50, 2}];
Graphics[{Blue, Point @ pts,
LightBlue, EdgeForm @ Gray, Polygon @ pts[[FindShortestTour[pts][[2]]]]}]
ConvexHull
.) $\endgroup$