# How to draw a 3D curve using ListPointPlot3D with continuously changing colours?

I have a list of points in the form of

data = {{x1, y1, z1}, {x2, y2, z2}, ......, {xn, yn, zn}}


and I can draw a 3D curve using the data using the command

Graphics3D[{Thickness[0.01], Line[data]}, Axes -> True].


However, I would like to have the colour of the curve changing continuously using a colour map. Basically I want a result similar to what one can do with ParametricPlot3D. For instance,

ParametricPlot3D[{Cos[t], 0, Sin[t]}, {t, 0, 2 Pi},
ColorFunction -> Function[{x, y, z, t}, ColorData["Rainbow"][t]]]


produces an output like below: How can I do the same thing when I have the data as a list of points?

## 2 Answers

Here is one way:

pnts = N@Table[{Cos[t], 0, Sin[t], t}, {t, 0, 2 Pi, Pi/20}];
pnts[[All, -1]] = Rescale[pnts[[All, -1]]];
Graphics3D[{Thickness[0.01],
Map[{ColorData["Rainbow"][Mean[#[[All, -1]]]], Line[Most /@ #]} &,
Partition[pnts, 2, 1]]}] My interpretation of "continuously changing colours" using CirclePoints , VertexColors and Hue

## Graphics3D

ListAnimate@With[
{
n = 30
},
Table[
Graphics3D[
{Thick,
Line[
Append[#, First[#]] &[
Prepend /@ CirclePoints[n]
]
, VertexColors -> RotateLeft[Array[Hue, n + 1, {0, 0.8}], k]
]
}
],
{k, n}
]] ## ListPointPlot3D

ListAnimate@
With[
{n = 50},
Table[
ListPointPlot3D[
List@*Prepend /@ CirclePoints[n]
, PlotStyle -> RotateLeft[Array[Hue, n + 1, {0, 0.8}], k]
, BoxRatios -> {1, 1, 1}
]
, {k, n}]
] 