diff options
author | tlacombe <lacombe1993@gmail.com> | 2019-12-16 17:19:44 +0100 |
---|---|---|
committer | tlacombe <lacombe1993@gmail.com> | 2019-12-16 17:19:44 +0100 |
commit | efebda596ae5a03dd0f15317ebfe74b5f19c78aa (patch) | |
tree | c21581669c5dcc985bed33fd043c0999f4e20e7d /src/python/example/plot_alpha_complex.py | |
parent | aba9ad68394b0c5aae22c450cac7162733132002 (diff) | |
parent | 3f1601665cbd0b7397c9c19f55d608246192207b (diff) |
Merge branch 'master' into wbary-theo
updating master in wbary-theo
Diffstat (limited to 'src/python/example/plot_alpha_complex.py')
-rwxr-xr-x | src/python/example/plot_alpha_complex.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/python/example/plot_alpha_complex.py b/src/python/example/plot_alpha_complex.py new file mode 100755 index 00000000..99c18a7c --- /dev/null +++ b/src/python/example/plot_alpha_complex.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import numpy as np +import gudhi +ac = gudhi.AlphaComplex(off_file='../../data/points/tore3D_1307.off') +st = ac.create_simplex_tree() +points = np.array([ac.get_point(i) for i in range(st.num_vertices())]) +# We want to plot the alpha-complex with alpha=0.1. +# We are only going to plot the triangles +triangles = np.array([s[0] for s in st.get_skeleton(2) if len(s[0])==3 and s[1] <= .1]) + +# First possibility: plotly +import plotly.graph_objects as go +fig = go.Figure(data=[ + go.Mesh3d( + x=points[:,0], + y=points[:,1], + z=points[:,2], + i = triangles[:,0], + j = triangles[:,1], + k = triangles[:,2], + ) +]) +fig.show() + +# Second possibility: matplotlib +from mpl_toolkits.mplot3d import Axes3D +import matplotlib.pyplot as plt +fig = plt.figure() +ax = fig.gca(projection='3d') +ax.plot_trisurf(points[:,0], points[:,1], points[:,2], triangles=triangles) +plt.show() + +# Third possibility: mayavi +from mayavi import mlab +mlab.triangular_mesh(points[:,0], points[:,1], points[:,2], triangles); +mlab.show() |