Plotting a Line in 3D from a List of Points

Click For Summary
SUMMARY

This discussion focuses on plotting lines in 3D using a list of points in Mathematica. Users can create 3D line graphics by utilizing the Graphics3D function along with the Line function. Specifically, the method involves partitioning a list of points into pairs using the Partition function, allowing for the creation of lines between consecutive points. The example provided demonstrates how to visualize a long list of points stored in a variable called 'dat' by executing Graphics3D[Line[Partition[dat, 2]]].

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of 3D graphics concepts
  • Knowledge of the Line and Graphics3D functions in Mathematica
  • Ability to manipulate lists and use the Partition function
NEXT STEPS
  • Explore the use of the Mathematica Graphics3D function for advanced 3D visualizations
  • Learn about the Partition function in Mathematica for data manipulation
  • Investigate additional 3D plotting techniques in Mathematica, such as Plot3D
  • Review best practices for importing and processing external data files in Mathematica
USEFUL FOR

This discussion is beneficial for data scientists, mathematicians, and software developers who are working with 3D visualizations in Mathematica and need to plot lines from a set of points efficiently.

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 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K