# How to make a correct contour plot of Arg[z]?

Let $$z \in \mathbb C$$ be an arbitrary complex number. Call it

• Red, if $$\Im(z^7) > 0$$
• Blue, if $$\Im(z^7) < 0$$
• Gray, if $$\Im(z^7) = 0$$.

I want to make a plot in which the red, blue and gray regions of the complex plane are painted in the appropriate color. I have the following helper function:

proc[f_, r_] := ComplexContourPlot[f, {z, 2},
Contours -> r, ContourShading -> {LightBlue, LightPink}];


The naïve way to use this function is

proc[Im[z^7], {0}]


This does not work as nicely as one would hope. The plot is distorted near the origin due to numerical stability issues in the calculation of $$\Im(z^7)$$ for very small $$z$$.

Another attempt would be

r = Range[-Pi, Pi, Pi/7];
proc[Arg[z], r]


This almost works, but not quite. The negative real axis is not painted correctly. This behavior is not unexpected, because Arg[z] is discontinuous at the negative real axis. But it is still annoying.

One rather ugly way to make this work is

p1 = proc[Arg[z], r];
p2 = proc[Arg[-z], {0}];
Show[p2, p1]


Is there anything less egregious than this that will still work?

• Is cranking up PlotPoints not an option? I don't have MM 12, so I can't use ComplexContourPlot, but using ContourPlot[Im[(x + I y)^7], {x, -2, 2}, {y, -2, 2}, PlotPoints -> 100] in MM 11 seems to give a reasonable result. May 14, 2020 at 18:02
• Building off @Michael's proposal, here's one way to color it: ContourPlot[Im[(x + I y)^7], {x, -2, 2}, {y, -2, 2}, ColorFunction -> (Blend[{Blue, Gray, Red}, LogisticSigmoid[10 #]] &), ColorFunctionScaling -> False, PlotPoints -> 100, PlotRange -> All] May 14, 2020 at 18:11
• @MichaelSeifert That did the trick, thanks!
– pyon
May 14, 2020 at 18:19

If processing time is not a concern, the option PlotPoints can be used to force Mathematica to perform more sampling of the function being plotted.
ComplexContourPlot[f, {z, 2},  Contours -> r,