3

So I have a 2D surface which can be parameterized by a vector $X(u1,u2)$ which I am plotting with ParametricPlot3D[X, {u1,...}, {u2,...}]

I have a scalar function, $f(u1,u2) \in [-fMax,fMax]$, which lives on this surface and I am trying to plot it as a heat map on the surface. I have tried this in the following way

ParametricPlot3D[
 X, {u1, 0, 2 Pi}, {u2, 0, 4 Pi},
 ColorFunction -> (ColorData[{"DarkRainbow",{-fMax,fMax}}][f[#1, #2] &])]

However this doesn't seem to work, as it gives something that is clearly wrong (doesn't match with the contour plot of the function).

Any help would be much appreciated!

kglr
  • 394,356
  • 18
  • 477
  • 896
Sami
  • 33
  • 3

1 Answers1

2

& is in the wrong place in ColorFunction option setting. You need to move it outside ColorFunction[...] and add the option ColorFunctionScaling -> False:

X = {(2 + Cos[u2]) Cos[u1], (2 + Cos[u2]) Sin[u1], Sin[u2]};
f = N@10 Sin[# + #2] &;
fMax = 10;
ParametricPlot3D[X, {u1, 0, 2 Pi}, {u2, 0, 4 Pi}, 
  ColorFunctionScaling -> False, 
  ColorFunction -> (ColorData[{"DarkRainbow", {-fMax, fMax}}][f[#1, #2]] &)]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896