I numerically calculate eigenfunctions in a different program and upload them to Mathematica as a .csv file. They are saved in a matrix form (x,y coordinates are indices, z coordinates are entry values). I would like to 'map' them back onto the original 3D surface to produce a heat map on said surface. How would I do that?

Example of the surface:

R = 2;
f[s_] := {R*Cos[s/R], R*Sin[s/R], 0};
fT[s_] := {-Sin[s/R], Cos[s/R], 0};
fN[s_] := {-Cos[s/R], -Sin[s/R], 0};
fB[s_] := {0, 0, 1};
a = R/2;
fTheta[s_] := Pi/2;
fStrip[s_, t_] := f[s] + t*(fN[s]*Cos[fTheta[s]] - fB[s]*Sin[fTheta[s]])
Show[ParametricPlot3D[{fStrip[s, t]}, {s, 0, 2*Pi*R}, {t, -a, a}, Mesh -> None]]
  • 1
    $\begingroup$ The example you provided doesn't seem adequate for demonstrating the situation, but I think you'd want to use the ColorFunction option. $\endgroup$
    – ktm
    Jan 29, 2018 at 19:26
  • $\begingroup$ Why is it not adequate? The code (should) generate a cylinder, by playing with the curve function f and angle function fTheta one can get loads of different 'ribbons'. My understanding is that to use the ColorFunction, I need to know what function the eigenfunction is. However, that is not possible as I get some generalizations of sines and cosines. Am I wrong? $\endgroup$
    – K Z
    Jan 30, 2018 at 17:26
  • $\begingroup$ How is that code going to generate a cylinder without any use of Plot, Graphics, or related functionality? $\endgroup$
    – ktm
    Jan 30, 2018 at 17:28
  • $\begingroup$ Sorry, I forgot to copy one line... My bad! $\endgroup$
    – K Z
    Jan 30, 2018 at 17:30
  • $\begingroup$ Can you provide a sample .csv file that includes the points you would want to map to that surface? (uploading to Pastebin or something might be best) $\endgroup$
    – ktm
    Jan 30, 2018 at 17:45

1 Answer 1


We first create some random data to use:

randomdata = Flatten[Table[{{s, t}, RandomReal[]}, {s, 0, 2 Pi R, 2 Pi R/60}, {t, -a, a, 2 a/20}], 1];

This yields a list of the form

(* {{{0, -1}, 0.758619}, {{0, -(9/10)}, 0.471565}, {{0, -(4/5)}, 0.539463}, ... *)

i.e., points of the form { { s_value, t_value}, fn_value}. Note that Table produces a nested list by default, so I had to use Flatten to get it into the correct form. Depending on the format of your original data, this may not be necessary.

Once you have your generated data in the correct form, you can use Interpolation to create a function that interpolates between them, and then feed this into ParametricPlot3D as a ColorFunction:

heatfn = Interpolation[randomdata];
ParametricPlot3D[{fStrip[s, t]}, {s, 0, 2*Pi*R}, {t, -a, a}, 
   Mesh -> None, 
   ColorFunction -> Function[{x, y, z, s, t}, ColorData["ThermometerColors"][heatfn[s, t]]], 
   ColorFunctionScaling -> False]

enter image description here

  • $\begingroup$ Thank you so much! I needed to convert my data, but in the end, it worked! :) $\endgroup$
    – K Z
    Feb 1, 2018 at 15:39

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