# Absolute value of $1$ in PlotLegends in ComplexPlot

When using PlotLegends -> "Automatic" in ComplexPlot, it seems that Mathematica always picks some value different from 1 on the absolute value bar. See here (it picked the value 1.3):

ComplexPlot[z, {z, 1}, PlotLegends -> Automatic]


Is there a way I can make the value 1 appear on the absolute value bar instead (for any given plot when the function attains 1 in absolute value)? I couldn't find it in the official documentation of ComplexPlot.

Looking at the source code of ComplexPlot, it seems that the ticks are hardcoded in SystemComplexPlotsDumpparseShadingLegend, and cannot be easily and reliably changed by user. You can request the feature to the Wolfram Technical Support.

However, let's break down how Mathematica picks the value anyway. It turns out that the automatically chosen value is the $$97.5 \%$$ percentile of acquired absolute values of the function on the given domain* (calculated in SystemComplexPlotsDumpcomplexPlotRasterGenerate).

f[z_] := z;

domainGrid =
Catenate@Table[
x + y I, {x, Subdivide[-1, 1, 144]}, {y, Subdivide[-1, 1, 144]}];
values = f /@ domainGrid;

Quantile[Flatten @ Abs @ values, 0.975] // N
(* 1.26785 *)

SystemComplexPlotsDumpmakeNiceNumber[%]
(* 1.3 *)


Without patching the source code, we can modify the ticks with this auxiliary function:

changeLegendTicks[vals_] :=
Function[cPlot,
cPlot /. {t1_, t2 : {p1_, v1_?NumberQ | NumberForm[v1_, __]},
t3_} :> {t1, Sequence @@ ({Rescale[#, {0, v1}, {t1[[1]], p1}], #} & /@ vals), t3}]

plot = ComplexPlot[z, {z, 1}, PlotLegends -> Automatic, ImageSize -> 200];

Row[{
plot, "     ",
plot // changeLegendTicks[{0.1, 0.5, 1}]
}]


Note that this is a "hacky way", and you should always check that the position of changed ticks is sensible.

*Domain is discretized into a grid with size RasterSize (144 by default, or 77 if PerformanceGoal -> "Speed", or whatever the user sets).

• @Vestoo In your request to Wolfram Tech Support ask that ComplexPlot support the OpacityFunction and OpactityFunctionScaling options similar to DensityPlot3D support of these options. Mar 30 at 12:09