Skip to content
Advertisement

How to create a multi-colored curve in 3d?

I’m trying to plot a 3d curve that has different colors depending on one of its parameters. I tried this method similar to this question, but it doesn’t work. Can anyone point me in the right direction?

JavaScript

Advertisement

Answer

To extend the approach in this tutorial to 3D, use x,y,z instead of x,y.

The desired shape for the segments is (number of segments, 2 points, 3 coordinates per point), so N-1,2,3. First the array of points is created with shape N, 3. Then start (xyz[:-1, :]) and end points (xyz[1:, :]) are stacked together.

JavaScript

example plot

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement