Creating a 3d "Road"

I’ve recently been using plotly in python to create a 3d scatter/line chart, and that’s worked quite well.

I’m graphing something that rotates as it moves though, and the line is the motion. As such, I’d like to find a way to show the rotation of the object over the path. I figure the best way to do this may be to create a graph that looks more like a “road” which rotates as the object does.

I can’t immediately see a way to do this though; surface plots don’t seem to be able to be limited to only sections like this or rotate like this, and I can’t find any 2d/flat markers to use for the line. Anyone have thoughts on how I could create this or what I should start researching?

Hi @nataelj,

Here are two ideas that come to mind.

  1. You could use a mesh3d trace. This would require computing the triangles that make up your “road”. Here’s an example with a moebius band https://plot.ly/python/surface-triangulation/#triangulation-of-the-moebius-band.

  2. If there is some natural interpretation of “up”, you could also consider displaying it using a cone trace (https://plot.ly/python/cone-plot/). Perhaps you could display the trajectory as a scatter3d line, and then overlay it with cones along the trajectory that are orthogonal to the line and point in the “up” direction.

Hope that helps give you some ideas,

-Jon

Thank you, those are both fantastic ideas! It took me this long to respond as it took me a while to implement either of these, but in the end I successfully have a cone graph implemented and it is great! And I may do the triangulation one as well at a later point, but for now the cone is sufficient.

I will note, for any who follow this chain, that while the cone graph is good, it doesn’t seem to have a capacity to change the color and size of the cones independently. As such, for this one needs to scale the cones by whatever variable is important to have them work with color. I’m in the middle of attempting to do that myself and getting sort of mixed results given that these are connected; a bit annoying and less useful than it could be, but still way better than nothing!

1 Like