# How do we color a plot based on a given function?

I'll explain the problem I have with a shorter example, since I'm working with a huge messy function. Suppose we have a real-function $$f(t)$$, and a curve $$C(t) \in \mathbb R^3$$. Now, I can use ParametricPlot3d to plot $$C(t)$$. My question is the following:

How do I color the curve $$C(t)$$ using the magnitude of $$f(t)$$ at each point, $$P(x(t),y(t),z(t)) \in C(t)$$.

I tried tinkering with ColorFunction for this, but was unsuccessful. Any hints would be appreciated.

Here is an example. I am making up f[t]

f[t_] := Cos[t]


I also make C[t]

ParametricPlot3D[{Sin[t], Cos[t], t/10}, {t, 0, 20},
ColorFunction -> Function[{x, y, z, t}, Hue[f[t]]]]


• Am I correct in understanding that the Hue[f[t]] assigns the colors in this case such that the lower magnitudes are red and the higher ones are blue ? – Lelouch Jun 8 '19 at 14:00
• @Lelouch: Just look up the documentation on Hue. – David G. Stork Jun 8 '19 at 17:15