# Plotting $f: x + i\,y \mapsto u + i\, v$ with Plot3D and mapping $v$ to color

Mathematica already has ComplexPlot3D that plots ReIm[x, y] against Abs[f(z)] and Arg[f(z)].

But what if I wanted to plot my function using an extension of the x,y,z space? For example, I might have a $$f(z) = z^2+1$$ and want to plot $$w = f(z)$$, where $$z = x + i y$$ and $$w = u + i v$$, in a more traditional way where the axes are $$x,y$$ and $$u$$ and for $$v$$ I would use colour.

Is this possible?

• Please explain exactly what you're trying to do. Is it to show two planes, one an xy-plane for the domain and the other a uv-plane for the codomain? (But then just what does "color" have to do with it?) And if so, what kind of "plot" do you want: there are various possibilities, such as plotting points in the first and their images under f in the second, or plotting families of curves in the first and their images under f in the second. – murray Apr 30 '19 at 15:30
• ok thats a fair question. Perhaps i should have explained. ok so if you plot 2 complex numbers z and f(z) you get 4 components re(z), img(z), re(f(z)) and img(f(z)) which means they are 4 variables. The normal way of plotting a 3d complex function in mathematica is to use img, re, abs and arg. But there is a different method where you just directly plot the graph in 4 dimensions using the 4 varibles. lets say f(z)=w and w=u+iv and z=x+iy. Which means we have a graph of x,y,u and v. but one of them needs to be the 'color' of the graph. we use color for the extra 4th dimension – Mofo50CX Apr 30 '19 at 17:12
• then I think the answer by BlacKow does exactly what you are asking for. – murray May 1 '19 at 14:25

I'm probably missing something, but have you tried using Plot3D with ColorFunction?

f[z_] := z^2 + 1;
Plot3D[Re@f[x + I*y], {x, -10, 10}, {y, -10, 10}, PlotRange -> Full,
ColorFunction -> Function[{x, y, z}, Hue@Im@f[x + I*y]]] It looks nice, but it's completely wrong, obviously if x=0 or y=0 the imaginary part is zero, so the color should be the same.

ColorFunctionScaling is messing things up as explained here.

So we need to disable automatic scaling and do it manually with 0.005 factor in ColorFunction

Plot3D[Re@f[x + I*y], {x, -10, 10}, {y, -10, 10}, PlotRange -> Full,
ColorFunction -> Function[{x, y, z}, Hue[0.005 Im@f[x + I*y]]],
ColorFunctionScaling -> False, PlotPoints -> 50] • yooo thanks so much man it works like a charm. can i just ask how i could add a bar legend that matches the colour to something. Also what does plotpoints do? – Mofo50CX May 23 '19 at 21:14