Curve angle represented with colored gradient

Hello community!

I am trying to color a curve (or pipe output from it) based on the gradient of that curve (so angle between the tangent on the curve and the y axis for instance). So I have divided it in a number of parts and tried to give different colors to each of them, but for some reason I don’t seem to get it right.

So basically if the segment of the curve is under 10 degrees, should be purple to red, if higher, green to blue or so. Could you help me understand what I did wrong? (21.5 KB)

this topic might help (9.3 KB)