Plotting a Line in 3D from a List of Points

AI Thread Summary
It is possible to plot a line in 3D from one point to another using a list of points. For example, two lists of points can be defined as List1 and List2, and combined into a single graphics object using Graphics3D. For users with a long list of points from an external file, the recommended approach is to use the Partition function to group the points into pairs. This can be done by defining the list as a variable (e.g., dat) and then using Graphics3D with Line[Partition[dat, 2]] to create the desired 3D line plot. This method effectively connects every two points in the list, facilitating the visualization of the data.
button_ger
Messages
10
Reaction score
0
Hey.

Is it possible to plot a line in 3D from one point to another?
The source of the points is a list.
 
Physics news on Phys.org
List1 = {{1, 1, 1}, {3, 4, 5}};
List2 = {{-3, 1, 2}, {2, 1, 5}};
L3 = {Line[List1], Line[List2]}
Graphics3D[L3, Axes -> True,
PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}]
 
Thank you.

I have a long list with points from an external file. How can i do this?
{{3,6,5},{2,4,1},{3,5,4},{6,7,4},{3,2,1},{1,1,1},...}

Every 2nd point should be the end-point of the line.
Or is it better to make it like this?
{{3,6,5,2,4,1},{3,5,4,6,7,4},{3,2,1,1,1,1},...}
 
Last edited:
button_ger said:
I have a long list with points from an external file. How can i do this?
{{3,6,5},{2,4,1},{3,5,4},{6,7,4},{3,2,1},{1,1,1},...}
If your long list of points is in a variable called dat (i.e. dat={{3,6,5},{2,4,1},{3,5,4},{6,7,4},{3,2,1},{1,1,1}}) then

Graphics3D[Line[Partition[dat,2]]]

will plot the lines
 
great support in this forums.

Thanks a lot DaleSpam.


greets
button
 

Similar threads

Replies
1
Views
2K
Replies
2
Views
2K
Replies
1
Views
2K
Replies
2
Views
2K
Replies
5
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Back
Top