summaryrefslogtreecommitdiff
path: root/src/python/example
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/example')
-rwxr-xr-xsrc/python/example/alpha_complex_diagram_persistence_from_off_file_example.py7
-rwxr-xr-xsrc/python/example/alpha_rips_persistence_bottleneck_distance.py2
-rwxr-xr-xsrc/python/example/diagram_vectorizations_distances_kernels.py133
-rwxr-xr-xsrc/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py9
-rwxr-xr-xsrc/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py9
-rwxr-xr-xsrc/python/example/gudhi_graphical_tools_example.py18
-rwxr-xr-xsrc/python/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py4
-rwxr-xr-xsrc/python/example/plot_alpha_complex.py37
-rwxr-xr-xsrc/python/example/plot_rips_complex.py38
-rwxr-xr-xsrc/python/example/plot_simplex_tree_dim012.py66
-rwxr-xr-xsrc/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py7
-rwxr-xr-xsrc/python/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py7
-rwxr-xr-xsrc/python/example/rips_complex_diagram_persistence_from_off_file_example.py9
-rwxr-xr-xsrc/python/example/rips_persistence_diagram.py5
-rwxr-xr-xsrc/python/example/sparse_rips_persistence_diagram.py5
-rwxr-xr-xsrc/python/example/tangential_complex_plain_homology_from_off_file_example.py7
16 files changed, 329 insertions, 34 deletions
diff --git a/src/python/example/alpha_complex_diagram_persistence_from_off_file_example.py b/src/python/example/alpha_complex_diagram_persistence_from_off_file_example.py
index b8f283b3..4079a469 100755
--- a/src/python/example/alpha_complex_diagram_persistence_from_off_file_example.py
+++ b/src/python/example/alpha_complex_diagram_persistence_from_off_file_example.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-import gudhi
import argparse
+import matplotlib.pyplot as plot
+import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -60,8 +61,8 @@ with open(args.file, "r") as f:
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- pplot = gudhi.plot_persistence_diagram(diag, band=args.band)
- pplot.show()
+ gudhi.plot_persistence_diagram(diag, band=args.band)
+ plot.show()
else:
print(args.file, "is not a valid OFF file")
diff --git a/src/python/example/alpha_rips_persistence_bottleneck_distance.py b/src/python/example/alpha_rips_persistence_bottleneck_distance.py
index 086307ee..d5c33ec8 100755
--- a/src/python/example/alpha_rips_persistence_bottleneck_distance.py
+++ b/src/python/example/alpha_rips_persistence_bottleneck_distance.py
@@ -35,7 +35,7 @@ args = parser.parse_args()
with open(args.file, "r") as f:
first_line = f.readline()
if (first_line == "OFF\n") or (first_line == "nOFF\n"):
- point_cloud = gudhi.read_off(off_file=args.file)
+ point_cloud = gudhi.read_points_from_off_file(off_file=args.file)
print("#####################################################################")
print("RipsComplex creation from points read in a OFF file")
diff --git a/src/python/example/diagram_vectorizations_distances_kernels.py b/src/python/example/diagram_vectorizations_distances_kernels.py
new file mode 100755
index 00000000..119072eb
--- /dev/null
+++ b/src/python/example/diagram_vectorizations_distances_kernels.py
@@ -0,0 +1,133 @@
+#!/usr/bin/env python
+
+import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.kernel_approximation import RBFSampler
+from sklearn.preprocessing import MinMaxScaler
+
+from gudhi.representations import DiagramSelector, Clamping, Landscape, Silhouette, BettiCurve, ComplexPolynomial,\
+ TopologicalVector, DiagramScaler, BirthPersistenceTransform,\
+ PersistenceImage, PersistenceWeightedGaussianKernel, Entropy, \
+ PersistenceScaleSpaceKernel, SlicedWassersteinDistance,\
+ SlicedWassersteinKernel, BottleneckDistance, PersistenceFisherKernel
+
+D = np.array([[0.,4.],[1.,2.],[3.,8.],[6.,8.], [0., np.inf], [5., np.inf]])
+diags = [D]
+
+diags = DiagramSelector(use=True, point_type="finite").fit_transform(diags)
+diags = DiagramScaler(use=True, scalers=[([0,1], MinMaxScaler())]).fit_transform(diags)
+diags = DiagramScaler(use=True, scalers=[([1], Clamping(maximum=.9))]).fit_transform(diags)
+
+D = diags[0]
+plt.scatter(D[:,0],D[:,1])
+plt.plot([0.,1.],[0.,1.])
+plt.title("Test Persistence Diagram for vector methods")
+plt.show()
+
+LS = Landscape(resolution=1000)
+L = LS.fit_transform(diags)
+plt.plot(L[0][:1000])
+plt.plot(L[0][1000:2000])
+plt.plot(L[0][2000:3000])
+plt.title("Landscape")
+plt.show()
+
+def pow(n):
+ return lambda x: np.power(x[1]-x[0],n)
+
+SH = Silhouette(resolution=1000, weight=pow(2))
+sh = SH.fit_transform(diags)
+plt.plot(sh[0])
+plt.title("Silhouette")
+plt.show()
+
+BC = BettiCurve(resolution=1000)
+bc = BC.fit_transform(diags)
+plt.plot(bc[0])
+plt.title("Betti Curve")
+plt.show()
+
+CP = ComplexPolynomial(threshold=-1, polynomial_type="T")
+cp = CP.fit_transform(diags)
+print("Complex polynomial is " + str(cp[0,:]))
+
+TV = TopologicalVector(threshold=-1)
+tv = TV.fit_transform(diags)
+print("Topological vector is " + str(tv[0,:]))
+
+PI = PersistenceImage(bandwidth=.1, weight=lambda x: x[1], im_range=[0,1,0,1], resolution=[100,100])
+pi = PI.fit_transform(diags)
+plt.imshow(np.flip(np.reshape(pi[0], [100,100]), 0))
+plt.title("Persistence Image")
+plt.show()
+
+ET = Entropy(mode="scalar")
+et = ET.fit_transform(diags)
+print("Entropy statistic is " + str(et[0,:]))
+
+ET = Entropy(mode="vector", normalized=False)
+et = ET.fit_transform(diags)
+plt.plot(et[0])
+plt.title("Entropy function")
+plt.show()
+
+D = np.array([[1.,5.],[3.,6.],[2.,7.]])
+diags2 = [D]
+
+diags2 = DiagramScaler(use=True, scalers=[([0,1], MinMaxScaler())]).fit_transform(diags2)
+
+D = diags[0]
+plt.scatter(D[:,0],D[:,1])
+D = diags2[0]
+plt.scatter(D[:,0],D[:,1])
+plt.plot([0.,1.],[0.,1.])
+plt.title("Test Persistence Diagrams for kernel methods")
+plt.show()
+
+def arctan(C,p):
+ return lambda x: C*np.arctan(np.power(x[1], p))
+
+PWG = PersistenceWeightedGaussianKernel(bandwidth=1., kernel_approx=None, weight=arctan(1.,1.))
+X = PWG.fit(diags)
+Y = PWG.transform(diags2)
+print("PWG kernel is " + str(Y[0][0]))
+
+PWG = PersistenceWeightedGaussianKernel(kernel_approx=RBFSampler(gamma=1./2, n_components=100000).fit(np.ones([1,2])), weight=arctan(1.,1.))
+X = PWG.fit(diags)
+Y = PWG.transform(diags2)
+print("Approximate PWG kernel is " + str(Y[0][0]))
+
+PSS = PersistenceScaleSpaceKernel(bandwidth=1.)
+X = PSS.fit(diags)
+Y = PSS.transform(diags2)
+print("PSS kernel is " + str(Y[0][0]))
+
+PSS = PersistenceScaleSpaceKernel(kernel_approx=RBFSampler(gamma=1./2, n_components=100000).fit(np.ones([1,2])))
+X = PSS.fit(diags)
+Y = PSS.transform(diags2)
+print("Approximate PSS kernel is " + str(Y[0][0]))
+
+sW = SlicedWassersteinDistance(num_directions=100)
+X = sW.fit(diags)
+Y = sW.transform(diags2)
+print("SW distance is " + str(Y[0][0]))
+
+SW = SlicedWassersteinKernel(num_directions=100, bandwidth=1.)
+X = SW.fit(diags)
+Y = SW.transform(diags2)
+print("SW kernel is " + str(Y[0][0]))
+
+W = BottleneckDistance(epsilon=.001)
+X = W.fit(diags)
+Y = W.transform(diags2)
+print("Bottleneck distance is " + str(Y[0][0]))
+
+PF = PersistenceFisherKernel(bandwidth_fisher=1., bandwidth=1.)
+X = PF.fit(diags)
+Y = PF.transform(diags2)
+print("PF kernel is " + str(Y[0][0]))
+
+PF = PersistenceFisherKernel(bandwidth_fisher=1., bandwidth=1., kernel_approx=RBFSampler(gamma=1./2, n_components=100000).fit(np.ones([1,2])))
+X = PF.fit(diags)
+Y = PF.transform(diags2)
+print("Approximate PF kernel is " + str(Y[0][0]))
diff --git a/src/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py b/src/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py
index 610ba44f..4903667e 100755
--- a/src/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py
+++ b/src/python/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-import gudhi
import argparse
+import matplotlib.pyplot as plot
+import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -46,7 +47,7 @@ with open(args.file, "r") as f:
print("#####################################################################")
print("EuclideanStrongWitnessComplex creation from points read in a OFF file")
- witnesses = gudhi.read_off(off_file=args.file)
+ witnesses = gudhi.read_points_from_off_file(off_file=args.file)
landmarks = gudhi.pick_n_random_points(
points=witnesses, nb_points=args.number_of_landmarks
)
@@ -75,8 +76,8 @@ with open(args.file, "r") as f:
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- pplot = gudhi.plot_persistence_diagram(diag, band=args.band)
- pplot.show()
+ gudhi.plot_persistence_diagram(diag, band=args.band)
+ plot.show()
else:
print(args.file, "is not a valid OFF file")
diff --git a/src/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py b/src/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py
index 7587b732..339a8577 100755
--- a/src/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py
+++ b/src/python/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-import gudhi
import argparse
+import matplotlib.pyplot as plot
+import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -45,7 +46,7 @@ with open(args.file, "r") as f:
print("#####################################################################")
print("EuclideanWitnessComplex creation from points read in a OFF file")
- witnesses = gudhi.read_off(off_file=args.file)
+ witnesses = gudhi.read_points_from_off_file(off_file=args.file)
landmarks = gudhi.pick_n_random_points(
points=witnesses, nb_points=args.number_of_landmarks
)
@@ -74,8 +75,8 @@ with open(args.file, "r") as f:
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- pplot = gudhi.plot_persistence_diagram(diag, band=args.band)
- pplot.show()
+ gudhi.plot_persistence_diagram(diag, band=args.band)
+ plot.show()
else:
print(args.file, "is not a valid OFF file")
diff --git a/src/python/example/gudhi_graphical_tools_example.py b/src/python/example/gudhi_graphical_tools_example.py
index 3b0ca54d..37ecbf53 100755
--- a/src/python/example/gudhi_graphical_tools_example.py
+++ b/src/python/example/gudhi_graphical_tools_example.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+import matplotlib.pyplot as plot
import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
@@ -29,15 +30,24 @@ persistence = [
(0, (0.0, 1.0)),
]
gudhi.plot_persistence_barcode(persistence)
+plot.show()
print("#####################################################################")
print("Show diagram persistence example")
-pplot = gudhi.plot_persistence_diagram(persistence)
-pplot.show()
+gudhi.plot_persistence_diagram(persistence)
+plot.show()
print("#####################################################################")
print("Show diagram persistence example with a confidence band")
-pplot = gudhi.plot_persistence_diagram(persistence, band=0.2)
-pplot.show()
+gudhi.plot_persistence_diagram(persistence, band=0.2)
+plot.show()
+
+print("#####################################################################")
+print("Show barcode and diagram persistence side by side example")
+fig, axes = plot.subplots(nrows=1, ncols=2)
+gudhi.plot_persistence_barcode(persistence, axes = axes[0])
+gudhi.plot_persistence_diagram(persistence, axes = axes[1])
+fig.suptitle("barcode versus diagram")
+plot.show()
diff --git a/src/python/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py b/src/python/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py
index 9cb855cd..c692e66f 100755
--- a/src/python/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py
+++ b/src/python/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-import gudhi
import argparse
+import matplotlib.pyplot as plot
+import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -70,5 +71,6 @@ if is_file_perseus(args.file):
print(periodic_cubical_complex.betti_numbers())
if args.no_barcode == False:
gudhi.plot_persistence_barcode(diag)
+ plot.show()
else:
print(args.file, "is not a valid perseus style file")
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()
diff --git a/src/python/example/plot_rips_complex.py b/src/python/example/plot_rips_complex.py
new file mode 100755
index 00000000..214a3c0a
--- /dev/null
+++ b/src/python/example/plot_rips_complex.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+import numpy as np
+import gudhi
+points = np.array(gudhi.read_points_from_off_file('../../data/points/Kl.off'))
+rc = gudhi.RipsComplex(points=points, max_edge_length=.2)
+st = rc.create_simplex_tree(max_dimension=2)
+# 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])
+
+# First possibility: plotly
+import plotly.graph_objects as go
+fig = go.Figure(data=[
+ go.Mesh3d(
+ # Use the first 3 coordinates, but we could as easily pick others
+ 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
+# (this may take a while)
+from mayavi import mlab
+mlab.triangular_mesh(points[:,0], points[:,1], points[:,2], triangles);
+mlab.show()
diff --git a/src/python/example/plot_simplex_tree_dim012.py b/src/python/example/plot_simplex_tree_dim012.py
new file mode 100755
index 00000000..5b962131
--- /dev/null
+++ b/src/python/example/plot_simplex_tree_dim012.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+import numpy as np
+import gudhi
+
+# Coordinates of the points
+points=np.array([[0,0,0],[1,0,0],[0,1,0],[0,0,1],[1,1,1],[1,1,0],[0,1,1]])
+# Build the simplicial complex with a tetrahedon, an edge and an isolated vertex
+cplx=gudhi.SimplexTree()
+cplx.insert([1,2,3,5])
+cplx.insert([4,6])
+cplx.insert([0])
+# List of triangles (point indices)
+triangles = np.array([s[0] for s in cplx.get_skeleton(2) if len(s[0])==3])
+# List of edges (point coordinates)
+edges = []
+for s in cplx.get_skeleton(1):
+ e = s[0]
+ if len(e) == 2:
+ edges.append(points[[e[0],e[1]]])
+
+## With plotly
+import plotly.graph_objects as go
+# Plot triangles
+f2 = go.Mesh3d(
+ x=points[:,0],
+ y=points[:,1],
+ z=points[:,2],
+ i = triangles[:,0],
+ j = triangles[:,1],
+ k = triangles[:,2],
+ )
+# Plot points
+f0 = go.Scatter3d(x=points[:,0], y=points[:,1], z=points[:,2], mode="markers")
+data = [f2, f0]
+# Plot edges
+for pts in edges:
+ seg = go.Scatter3d(x=pts[:,0],y=pts[:,1],z=pts[:,2],mode="lines",line=dict(color='green'))
+ data.append(seg)
+fig = go.Figure(data=data,layout=dict(showlegend=False))
+# By default plotly would give each edge its own color and legend, that's too much
+fig.show()
+
+## With matplotlib
+from mpl_toolkits.mplot3d import Axes3D
+from mpl_toolkits.mplot3d.art3d import Line3DCollection
+import matplotlib.pyplot as plt
+fig = plt.figure()
+ax = fig.gca(projection='3d')
+# Plot triangles
+ax.plot_trisurf(points[:,0], points[:,1], points[:,2], triangles=triangles)
+# Plot points
+ax.scatter3D(points[:,0], points[:,1], points[:,2])
+# Plot edges
+ax.add_collection3d(Line3DCollection(segments=edges))
+plt.show()
+
+## With mayavi
+from mayavi import mlab
+# Plot triangles
+mlab.triangular_mesh(points[:,0], points[:,1], points[:,2], triangles);
+# Plot points
+mlab.points3d(points[:,0], points[:,1], points[:,2])
+# Plot edges
+for pts in edges:
+ mlab.plot3d(pts[:,0],pts[:,1],pts[:,2],tube_radius=None)
+mlab.show()
diff --git a/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py b/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py
index 3571580b..1acb187c 100755
--- a/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py
+++ b/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py
@@ -1,8 +1,9 @@
#!/usr/bin/env python
-import gudhi
import sys
import argparse
+import matplotlib.pyplot as plot
+import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -83,5 +84,5 @@ invert_diag = [
]
if args.no_diagram == False:
- pplot = gudhi.plot_persistence_diagram(invert_diag, band=args.band)
- pplot.show()
+ gudhi.plot_persistence_diagram(invert_diag, band=args.band)
+ plot.show()
diff --git a/src/python/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py b/src/python/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py
index 0b9a9ba9..79ccca96 100755
--- a/src/python/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py
+++ b/src/python/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-import gudhi
import argparse
+import matplotlib.pyplot as plot
+import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -59,5 +60,5 @@ print("betti_numbers()=")
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- pplot = gudhi.plot_persistence_diagram(diag, band=args.band)
- pplot.show()
+ gudhi.plot_persistence_diagram(diag, band=args.band)
+ plot.show()
diff --git a/src/python/example/rips_complex_diagram_persistence_from_off_file_example.py b/src/python/example/rips_complex_diagram_persistence_from_off_file_example.py
index 2b335bba..c757aca7 100755
--- a/src/python/example/rips_complex_diagram_persistence_from_off_file_example.py
+++ b/src/python/example/rips_complex_diagram_persistence_from_off_file_example.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-import gudhi
import argparse
+import matplotlib.pyplot as plot
+import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -47,7 +48,7 @@ with open(args.file, "r") as f:
message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length)
print(message)
- point_cloud = gudhi.read_off(off_file=args.file)
+ point_cloud = gudhi.read_points_from_off_file(off_file=args.file)
rips_complex = gudhi.RipsComplex(
points=point_cloud, max_edge_length=args.max_edge_length
)
@@ -64,8 +65,8 @@ with open(args.file, "r") as f:
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- pplot = gudhi.plot_persistence_diagram(diag, band=args.band)
- pplot.show()
+ gudhi.plot_persistence_diagram(diag, band=args.band)
+ plot.show()
else:
print(args.file, "is not a valid OFF file")
diff --git a/src/python/example/rips_persistence_diagram.py b/src/python/example/rips_persistence_diagram.py
index f5897d7b..2a90b4bc 100755
--- a/src/python/example/rips_persistence_diagram.py
+++ b/src/python/example/rips_persistence_diagram.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+import matplotlib.pyplot as plot
import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
@@ -26,5 +27,5 @@ simplex_tree = rips.create_simplex_tree(max_dimension=1)
diag = simplex_tree.persistence(homology_coeff_field=2, min_persistence=0)
print("diag=", diag)
-pplot = gudhi.plot_persistence_diagram(diag)
-pplot.show()
+gudhi.plot_persistence_diagram(diag)
+plot.show()
diff --git a/src/python/example/sparse_rips_persistence_diagram.py b/src/python/example/sparse_rips_persistence_diagram.py
index 671d5e34..410a6a86 100755
--- a/src/python/example/sparse_rips_persistence_diagram.py
+++ b/src/python/example/sparse_rips_persistence_diagram.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+import matplotlib.pyplot as plot
import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
@@ -28,5 +29,5 @@ simplex_tree = rips.create_simplex_tree(max_dimension=2)
diag = simplex_tree.persistence(homology_coeff_field=2, min_persistence=0)
print("diag=", diag)
-pplot = gudhi.plot_persistence_diagram(diag)
-pplot.show()
+gudhi.plot_persistence_diagram(diag)
+plot.show()
diff --git a/src/python/example/tangential_complex_plain_homology_from_off_file_example.py b/src/python/example/tangential_complex_plain_homology_from_off_file_example.py
index 456bc9eb..f0df2189 100755
--- a/src/python/example/tangential_complex_plain_homology_from_off_file_example.py
+++ b/src/python/example/tangential_complex_plain_homology_from_off_file_example.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-import gudhi
import argparse
+import matplotlib.pyplot as plot
+import gudhi
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -56,8 +57,8 @@ with open(args.file, "r") as f:
print(st.betti_numbers())
if args.no_diagram == False:
- pplot = gudhi.plot_persistence_diagram(diag, band=args.band)
- pplot.show()
+ gudhi.plot_persistence_diagram(diag, band=args.band)
+ plot.show()
else:
print(args.file, "is not a valid OFF file")