Mathematica Mathematica Spatial 3-D List Plot

AI Thread Summary
To plot a list of 3D points in Mathematica and connect consecutive pairs with lines, use the Graphics3D function with Line. The basic syntax is Graphics3D[Line[dat]], where 'dat' is your list of points. For plotting multiple sets of data with different colors in a single box, combine the lines into one Graphics3D call, specifying colors for each line within the same structure. The challenge lies in correctly formatting the input to achieve the desired visual output. This approach allows for clear representation of multiple colored lines in a unified 3D plot.
brydustin
Messages
201
Reaction score
0
I want to plot a list of points where each element is of the form {x,y,z} so that the list is like:

{ {x1,y1,z1} , {x2,y2,z2} , ... , {xN,yN,zN} }.

And I want to connect a line between each consectutive pair (i.e. {x(i-1),y(i-1),z(i-1)} & {x(i),y(i),z(i)} ).

Unfortunately, its not as simple as ListLinePlot[List, Joined -> True], what this will do is take each {x(j),y(j),z(j)} and plot them each as separate lines each with 3 points in 2-D space.

Also, its not as simple as ListPlot3D[List, Joined -> True]
Because the Joined function is not defined in 3-D. But surely there is a way around this?
...
 
Physics news on Phys.org
Assuming your list is stored in a variable named dat:

Graphics3D[Line[dat]]
 
DaleSpam said:
Assuming your list is stored in a variable named dat:

Graphics3D[Line[dat]]

Now that I know the name of the function, I'm not sure how I might plot two sets of data, like dat1 and dat2 where the lines are color1 and color2, for example.
 
I think they have examples in the online help for Line.
 
DaleSpam said:
I think they have examples in the online help for Line.

Specifically, I wanted to know how to have multiple different colored lines in a box, but what they show is how to have multiple sets of lines with different colors however not in the same box, their example:

l = Line[{{1, 1, -1}, {2, 2, 1}, {3, 3, -1}, {4, 4, 1}}];
{Graphics3D[{Dashed, l}], Graphics3D[{Pink, l}],
Graphics3D[{Thick, l}], Graphics3D[{Thick, Dashed, Pink, l}]}

Which makes four boxes, I want one box with 4 lines each with a different color, for example.
 

Similar threads

Replies
1
Views
2K
Replies
1
Views
2K
Replies
4
Views
2K
Replies
3
Views
2K
Replies
2
Views
1K
Replies
2
Views
2K
Replies
22
Views
3K
Replies
3
Views
2K
Replies
6
Views
4K
Back
Top