# How can I add a custom color function and a custom mesh to a 3D parametric plot?

Consider a pseudosphere,

$\qquad \{x,y,z\} = \{\sin[u] \cos[v],\, \sin[u] \sin[v], \, \log[\tan[u/2]\}$.

Now I want to draw the figure.

 ParametricPlot3D[
{Sin[u] Cos[v], Sin[u] Sin[v], Log[Tan[u/2]] + Cos[u]},
{u, -2 π, 2 π}, {v, -2 π, 2 π}]


Now I want to have the plot show the following:

1. All points with equal third coordinate has the same color.

2. A curve with constant third coordinate is shown on the surface. it is equal to $\cos(u)\cot(u) = 0$.

I don't know how to combine these requirements. I tried

ParametricPlot3D[
{Sin[u] Cos[v], Sin[u] Sin[v], Log[Tan[u/2]] + Cos[u]},
{u, -2 π, 2 π}, {v, -2 π, 2 π},
PlotStyle -> Thick,
Mesh -> 10,
MeshFunctions -> {ConditionalExpression[#, f'[#] == 0] &}]


but it didn't help.

Any help I get here will be appreciated!

• Something like this MeshFunctions -> {#3 &}, ColorFunction -> (Hue[#3] &)? Mar 5 '18 at 19:30
• @swish I guess that doesn't give us a $cos(x) = 0$ property Mar 5 '18 at 19:54
• And where $cos(x)=0$ comes from? Mar 5 '18 at 20:01
• @swish from second property : curve with constant third coordinate is curve according to $z'(u) = 0 = cos(u)cot(u)$, i.e. $cos(u) = 0$ Mar 5 '18 at 20:23
• @swish I thought about using ConditionalExpression in MeshFunctions Mar 5 '18 at 20:24

The following gives a plot of the pseudosphere with coloring according to its z-coordinates.

p1 =
ParametricPlot3D[
{Sin[u] Cos[v], Sin[u] Sin[v], Log[Tan[u/2]] + Cos[u]},
{u, -2 π, 2 π}, {v, -2 π, 2 π},
PlotPoints -> 20,
MaxRecursion -> 3,
ColorFunction -> ((Hue[Abs@#3]) &),
ColorFunctionScaling -> False,
Mesh -> None,
Lighting -> "Neutral"] To find where Cos[u] Cot[u] == 0 holds in the domain -2 π <= u <= 2 π, I evaluate

uVals =
DeleteDuplicates[u /. Solve[Cos[u] Cot[u] == 0 && -2 π <= u <= 2 π, u]]


which gives

{-((3 π)/2), -(π/2), π/2, (3 π)/2}

The z-coordinates corresponding to these values of u are

zVals = Log[Tan[#/2]] + Cos[#] & /@ uVals


{0, I π, 0, I π}

So the only curve satisfying your condition is at z == 0, which occurs at two u values and I arbitrarily pick u == π/2.

The curve can be plotted with

p2 =
ParametricPlot3D[
Evaluate[{Sin[u] Cos[v], Sin[u] Sin[v], Log[Tan[u/2]] + Cos[u]} /. u -> π/2],
{u, -2 π, 2 π}, {v, -2 π, 2 π},
MeshStyle -> Directive[Black, AbsoluteThickness]];


p2 is not interesting plotted on its own, so I will only show it combined with p1, which I now give

Show[p1, p2]


plot2 Specify all the solution points for Mesh parameter:

Mesh -> {u /. Solve[z'[u] == 0 && -2 \[Pi] <= u <= 2 \[Pi], u], 0}

• z isn't a function as I think Mar 5 '18 at 22:04
• @openspace z[u_]=Log[Tan[u/2]] + Cos[u] Mar 5 '18 at 22:24