# Coloring some prescribed points in a 2D Graphic

I am doing some graphic of roots of the polynomial $$f(x)=x^{18}-50x^5-1$$. The roots are represented in the complex plane as in figure below:

To do that, I used the command

f[x_] :=x^18-50*x^5-1; ComplexListPlot[x /. Solve[f[x] == 0, x],PlotStyle -> PointSize[Large]]

However, I would like to colour (only) the $$5$$ inner points in red. Is it possible? Could you please help me?

 f[x_] := x^18 - 50*x^5 - 1;

ComplexListPlot[x /. Solve[f[x] == 0, x],
PlotStyle -> PointSize[Large],
ColorFunction -> (If[#4 <= .5, Red, Blue] &)]


• Thank you very much!!!
– Jean
Feb 7, 2022 at 12:57
• @Jean, my pleasure. Thank you for the accept.
– kglr
Feb 7, 2022 at 13:01

We can sort the roots by their Abs or Norm and color the first k points in red.

f[x_] = x^18 - 50*x^5 - 1;
sol = SolveValues[f[x] == 0, x];
pts = SortBy[sol, Abs, NumericalOrder];
k = 5;
ComplexListPlot[{pts[[1 ;; k]], pts[[k + 1 ;; -1]]},
PlotStyle -> {Red, Blue}]


Using RegionMember can be advantageous if a region definition is available.

sol = x /. Solve[f[x] == 0, x] // N
ptsA = ReIm /@ sol // N


Find the points from sol that are inside the region of interest:

pos = RegionMember[Disk[{0, 0}, 0.6], ptsA]
pts01 = Pick[sol, pos]

pts02 = Pick[sol, Not /@ pos]


Plot:

ComplexListPlot[{pts01, pts02}
, PlotStyle -> {{AbsolutePointSize[8], Red}, {AbsolutePointSize[8],
Blue}}
, Frame -> True
, Prolog -> {Lighter@Green, Opacity[0.5], Disk[{0, 0}, 0.6]}
]


Result: