3
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ Welcome! It would help, if you would extend (by editing) the description of the problem a little bit. Please give a defintiion of f and X add the output you get, and if possible, a example of the output you would like to have. Note, that you can qutie easily paste images to the post. $\endgroup$ – Johu Sep 4 '18 at 11:39
  • $\begingroup$ Is this similar to what you need? Density plot on the surface of sphere $\endgroup$ – Johu Sep 4 '18 at 11:40
  • $\begingroup$ If you want to supply the parameterization parameters to the color function, you should use the last two slots: f[#4, #5] &. $\endgroup$ – Henrik Schumacher Sep 4 '18 at 11:51
1
$\begingroup$

& 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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.