20

13

Is there a way to dynamically define a polygon on a plot (I'm working with `ListPlot`

and `SmoothDensityHistogram`

) to select a cluster of interest, and give the positions of those points in the original list of data?

I'd appreciate any help!

Here's just an example set of points:

```
x = {
{RandomReal[{0, 5}, 20],
RandomReal[{4, 4.5}, 10]},
{RandomReal[1, 20],
RandomReal[{1.5, 2}, 10]}
};
points = Transpose[Join @@@ x] ~RandomSample~ 30;
SmoothDensityHistogram[points, ColorFunction -> "TemperatureMap"]
ListPlot[points, PlotRange -> {{0, 5.5}, {0, 2.5}}]
```

3

Press CTRL-D to open the drawing tools, then draw a polygon. Select the polygon, copy it, and paste it back into an input cell to get the vertex coordinates. Then filter the points based on whether they're in the polygon. Someone will probably write a Manipulate with a Paste button to do this automatically.

– Szabolcs – 2012-03-27T11:40:18.313