Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Gnuplot: Plotting a 3D Triangulation

📅 2011-Jan-25 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ gnuplot, triangulations ⬩ 📚 Archive


Gnuplot can be used to plot or write to file existing 3D triangulations. Though its output is not fancy or beautiful, it can be a quick tool to check results. Here is how to render:

  1. A 3D triangulation or 3D surface mesh consists of tetrahedrons or triangles. Write the triangulation as a list of line segments to a text file. If the triangulation consists of tetrahedrons, then these could be the edges of the tetrahedrons. The line segments file should be written in the following format: ``` 3 4 9 6 9 1

10 45 78 23 67 90

Note that the 3D coordinates of each of the two vertices of a line segment should lie on separate lines. Also, each pair of point coordinates is separated from the next by 2 newlines. This is the format required by Gnuplot.

  2. Open Gnuplot, plot the segments file using `points`, `lines` or `linespoints` using a **surface plot**: ```
gnuplot> splot "Segments.txt" with lines

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧