# Selecting a circular region in 2D scatter plot

I have a 2D scatter plot. Now I want to select a circular region in this plot and use the data inside the circular region for further analysis. Is there any way to do that?

Using Select and Norm:

pts = RandomReal[10, {1000, 2}];
center = {5, 3};
good = Select[pts, Norm[# - center] < radius &];

Show[ListPlot[{pts, good}], Graphics@Circle[center, radius],  AspectRatio -> 1]


• Your last line could be a bit simpler ListPlot[{pts, good}, AspectRatio -> Automatic, Epilog -> Circle[center, radius]] ;-) – Vitaliy Kaurov Apr 18 '18 at 20:04
• That's right :) Could you explain why AspectRatio -> Automatic is not the same as default? – anderstood Apr 18 '18 at 20:34
• This should give you a hint: GoldenRatio AspectRatio /. AbsoluteOptions[ListPlot[{}]] – Vitaliy Kaurov Apr 18 '18 at 21:46
• @VitaliyKaurov I don't know why I expect Automatic settings to be default. A bit like in NDSolve, Method -> Automatic does not change anything (afaik). – anderstood Apr 19 '18 at 1:14

I'd use Nearest instead of Select, as it is much faster. Compare

pts = RandomReal[10, {10^5, 2}];
center = {5, 3};

sub1 = Select[pts, Norm[# - center] < radius &]; // AbsoluteTiming


{0.538735, Null}

sub2 = Nearest[pts, center, {All, radius}]; // AbsoluteTiming


{0.002293, Null}

ListPlot[{pts, #}, ImageSize -> 400, AspectRatio -> Automatic] & /@ {sub1, sub2}


The points sets might differ due to different boundary inclusion interpretation by Nearest and Select. But those could be easily adjusted by the radius value.