summaryrefslogtreecommitdiff
path: root/src/python/gudhi/clustering
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-05-25 17:45:22 +0200
committerMarc Glisse <marc.glisse@inria.fr>2020-05-25 17:45:22 +0200
commitee56ee7814367c8b7437c8a8d9a0be32877c3196 (patch)
tree535d418e3e6e8d6b358afd8130f2a36d6f72c819 /src/python/gudhi/clustering
parent8c122a8c92285dd89844720c9cf04d001db491d0 (diff)
plotting almost empty diagrams
Diffstat (limited to 'src/python/gudhi/clustering')
-rw-r--r--src/python/gudhi/clustering/tomato.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/python/gudhi/clustering/tomato.py b/src/python/gudhi/clustering/tomato.py
index 2b4d9242..824b5544 100644
--- a/src/python/gudhi/clustering/tomato.py
+++ b/src/python/gudhi/clustering/tomato.py
@@ -222,21 +222,19 @@ class Tomato:
"""
import matplotlib.pyplot as plt
+ l = self.max_density_per_cc_.min()
+ r = self.max_density_per_cc_.max()
if self.diagram_.size > 0:
plt.plot(self.diagram_[:, 0], self.diagram_[:, 1], "ro")
- l = self.diagram_[:, 1].min()
- r = max(self.diagram_[:, 0].max(), self.max_density_per_cc_.max())
- else:
- l = self.max_density_per_cc_.min()
- r = self.max_density_per_cc_.max()
- #FIXME: move this out of the else, for diagrams with one point on the diagonal and an infinite point with the same coordinate?
- if l == r:
- if l > 0:
- l, r = .9 * l, 1.1 * r
- elif l < 0:
- l, r = 1.1 * l, .9 * r
- else:
- l, r = -1., 1.
+ l = min(l, self.diagram_[:, 1].min())
+ r = max(r, self.diagram_[:, 0].max())
+ if l == r:
+ if l > 0:
+ l, r = .9 * l, 1.1 * r
+ elif l < 0:
+ l, r = 1.1 * l, .9 * r
+ else:
+ l, r = -1., 1.
plt.plot([l, r], [l, r])
plt.plot(
self.max_density_per_cc_, numpy.full(self.max_density_per_cc_.shape, 1.1 * l - 0.1 * r), "ro", color="green"