There are many algorithms to compute whether a point is contained within a polygon. They are fairly involved, and so I'll leave that to you if you'd like to recreate them. The package PolygonOps.jl include Point-in-poly testing, so I'd recommend starting there. You could sort the plotted points based on whether or not they are inside the polygon, and plot them with according colors. Then you could return the ones found to be inside. Below is an implementation.
using PolygonOps
using Plots
function do_poly_check(points,poly)
p = plot();
points_inside = []
for i in points
if PolygonOps.inpolygon(i,poly)!=0
scatter!(i,color = :blue)
push!(points_inside,i)
else
scatter!(i,color = :red)
end
end
display(p)
return points_inside
end
An example in action would then look like this:
points = [
(0,0),
(0,1),
(1,1),
(2,1),
(3,1),
(4,2),
]
poly = [
(0,0),
(1,0),
(1,1),
(0,1),
(0,0),
]
do_poly_check(points,poly)
Note that you did not specify to plot the polygon itself, although it could be done on the same scatterplot.