# Is it possible to use other varibles to color a line when using ColorFunction?

I know that in Plot or ListLinePlot functions, we can color the line by specify the ColorFunction option, and then the line will be colored according to the variables such as the y coordinate. For example,

ListLinePlot[{{0, -0.5}, {0.5, 1}, {1, -1.0}},
ColorFunction -> "TemperatureMap", PlotStyle -> Thickness[0.01]]


My question is whether it is possible to use the third variable to specify the color of the line, namely the $$x$$ and $$y$$ variables are just the coordinates and the value at this point is $$z$$. The background of my question is that I have obtained the solution $$z$$ at the line nodes $$(x,y)$$, and I want to use this value to color the connecting line.

If you have a list of {x, y, z} points, you could try this:

pts = Table[{x, x^2, 2 Sin[x]}, {x, 0, 4 \[Pi], 0.1 \[Pi]}];
Graphics[{
AbsoluteThickness[3],
Line[pts[[All, {1, 2}]],
VertexColors ->
ColorData["TemperatureMap"] /@ Rescale[pts[[All, 3]]]]
},
AspectRatio -> 1,
Frame -> True
]


You can feed Graphics all of the same options as ListLinePlot, so you should be able to achieve whatever style you want.