summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com>2019-11-28 10:01:12 +0100
committerGitHub <noreply@github.com>2019-11-28 10:01:12 +0100
commit03efe417c85f5fb913cc0bc8dd2bd7173e8dd3f6 (patch)
tree49875a6c73273e301d0c4e80ce9affba378bc9d0 /src
parent71c1facc409f08f459c73e15c853782240e51d25 (diff)
parentdbb5183230e4b16bd36c5d582ef82e880741f149 (diff)
Merge pull request #160 from VincentRouvreau/persistence_graphical_tool_fix
Persistence graphical tool fix
Diffstat (limited to 'src')
-rw-r--r--src/python/doc/persistence_graphical_tools_user.rst13
-rw-r--r--src/python/gudhi/persistence_graphical_tools.py5
2 files changed, 12 insertions, 6 deletions
diff --git a/src/python/doc/persistence_graphical_tools_user.rst b/src/python/doc/persistence_graphical_tools_user.rst
index 2de99252..f41a926b 100644
--- a/src/python/doc/persistence_graphical_tools_user.rst
+++ b/src/python/doc/persistence_graphical_tools_user.rst
@@ -67,10 +67,17 @@ If you want more information on a specific dimension, for instance:
import matplotlib.pyplot as plot
import gudhi
-
# rips_on_tore3D_1307.pers obtained from write_persistence_diagram method
persistence_file=gudhi.__root_source_dir__ + \
'/data/persistence_diagram/rips_on_tore3D_1307.pers'
- gudhi.plot_persistence_density(persistence_file=persistence_file,
- max_intervals=0, dimension=1, legend=True)
+ birth_death = gudhi.read_persistence_intervals_in_dimension(
+ persistence_file=persistence_file,
+ only_this_dim=1)
+ pers_diag = [(1, elt) for elt in birth_death]
+ # Use subplots to display diagram and density side by side
+ fig, axes = plot.subplots(nrows=1, ncols=2, figsize=(12, 5))
+ gudhi.plot_persistence_diagram(persistence=pers_diag,
+ axes=axes[0])
+ gudhi.plot_persistence_density(persistence=pers_diag,
+ dimension=1, legend=True, axes=axes[1])
plot.show()
diff --git a/src/python/gudhi/persistence_graphical_tools.py b/src/python/gudhi/persistence_graphical_tools.py
index c9dab323..7d232c85 100644
--- a/src/python/gudhi/persistence_graphical_tools.py
+++ b/src/python/gudhi/persistence_graphical_tools.py
@@ -369,7 +369,6 @@ def plot_persistence_density(
persistence_dim = read_persistence_intervals_in_dimension(
persistence_file=persistence_file, only_this_dim=dimension
)
- print(persistence_dim)
else:
print("file " + persistence_file + " not found.")
return None
@@ -417,10 +416,10 @@ def plot_persistence_density(
zi = k(np.vstack([xi.flatten(), yi.flatten()]))
# Make the plot
- axes.pcolormesh(xi, yi, zi.reshape(xi.shape), cmap=cmap)
+ img = axes.pcolormesh(xi, yi, zi.reshape(xi.shape), cmap=cmap)
if legend:
- axes.colorbar()
+ plt.colorbar(img, ax=axes)
axes.set_xlabel("Birth")
axes.set_ylabel("Death")