# Issue with using complexplot with Nearest

I have been trying to create a certain fractal with Mathematica but the main issue is that if I try and do something like

ComplexPlot[
Nearest[{I, -2 + I, 3 - 2 I}, z],
{z, -2 - 2 I, 2 + 2 I}
]


and then try to graph it, I keep getting these error messages:

Nearest::neard: The default distance function does not give a real numeric distance when applied to the point pair z and I.
Nearest::neard The default distance function does not give a real numeric distance when applied to the point pair SystemComplexPlotsDumpnz\$. and I.
General::stop: Further output of Nearest::neard will be suppressed during this calculation.

I have tried doing this with normal plot and real numbers, which works just fine, and I know that nearest can handle complex numbers as it can do things like Nearest[{I + 2, 3I}, 0] and will output 2 + I. So the issue is something with ComplexPlot. The final image given is also just a red square, which is unexpected. Anyone know how to help?

New contributor
Brandon Nadel is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Perhaps an indirect approach might succeed: nf = Nearest[{I, -2 + I, 3 - 2 I}]; nfx[z_?NumericQ] := nf[z] and then try using nfx[z] instead in your plot. Jun 20 at 17:47
• @J.M. I tried that and the errors are no longer showing up but the output it still a large red box, which shouldn't be showing up Jun 20 at 17:53
• Ah, if you tried evaluating nfx[] at some arbitrary argument, you'd find that it gives a list and not a number. Perhaps nfx[z_?NumericQ] := First[nf[z]] is what you wanted instead? Jun 20 at 17:56
• @J.M. that works, thanks Jun 20 at 18:01

Clear[ne]