# 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] &)? – swish Mar 5 '18 at 19:30
• @swish I guess that doesn't give us a $cos(x) = 0$ property – openspace Mar 5 '18 at 19:54
• And where $cos(x)=0$ comes from? – swish 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$ – openspace Mar 5 '18 at 20:23
• @swish I thought about using ConditionalExpression in MeshFunctions – openspace 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 – openspace Mar 5 '18 at 22:04
• @openspace z[u_]=Log[Tan[u/2]] + Cos[u] – swish Mar 5 '18 at 22:24
{"ft_lang_label":"__label__en","ft_lang_prob":0.73599863,"math_prob":0.9901995,"size":858,"snap":"2020-34-2020-40","text_gpt3_token_len":302,"char_repetition_ratio":0.11241218,"word_repetition_ratio":0.18439716,"special_character_ratio":0.40675992,"punctuation_ratio":0.1969697,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99799836,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,5,null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-25T23:06:32Z\",\"WARC-Record-ID\":\"<urn:uuid:51ee8bb9-712d-4b26-9db6-9a709680b408>\",\"Content-Length\":\"165203\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bb6f9f88-9340-4e8b-b50b-5c55b03e716b>\",\"WARC-Concurrent-To\":\"<urn:uuid:725af1c7-caf5-4dda-8969-2e33d2240c56>\",\"WARC-IP-Address\":\"151.101.1.69\",\"WARC-Target-URI\":\"https://mathematica.stackexchange.com/questions/167196/how-can-i-add-a-custom-color-function-and-a-custom-mesh-to-a-3d-parametric-plot\",\"WARC-Payload-Digest\":\"sha1:UBRAUQKDK3KK4OWXM3YRNAQB3V5ZE3HC\",\"WARC-Block-Digest\":\"sha1:IBIFFPVVPX6E2GLZVPBVPL2DDLYGS6RG\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400228998.45_warc_CC-MAIN-20200925213517-20200926003517-00591.warc.gz\"}"}