summaryrefslogtreecommitdiff
path: root/src/python/doc
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-06-05 23:05:34 +0200
committerMarc Glisse <marc.glisse@inria.fr>2020-06-05 23:05:34 +0200
commit299a62e6ec581e5095c9fdc73e454f35ed88f711 (patch)
tree8315d238294389f28673c7e83be47a45826892a4 /src/python/doc
parent02baef8170649f917882db727156636315bae8cf (diff)
Autogenerate the images when building the doc
It does slow down building the doc significantly though.
Diffstat (limited to 'src/python/doc')
-rw-r--r--src/python/doc/clustering.rst32
-rw-r--r--src/python/doc/img/spiral-density.pngbin442666 -> 0 bytes
-rw-r--r--src/python/doc/img/spiral-diag.pngbin23621 -> 0 bytes
-rw-r--r--src/python/doc/img/spiral-diag2.pngbin29403 -> 0 bytes
-rw-r--r--src/python/doc/img/spiral.pngbin306629 -> 0 bytes
5 files changed, 16 insertions, 16 deletions
diff --git a/src/python/doc/clustering.rst b/src/python/doc/clustering.rst
index 1e933dc9..c5a57d3c 100644
--- a/src/python/doc/clustering.rst
+++ b/src/python/doc/clustering.rst
@@ -12,7 +12,9 @@ The merging phase depends on a parameter, which is the minimum prominence a clus
As a by-product, we produce the persistence diagram of the merge tree of the initial clusters. This is a convenient graphical tool to help decide how many clusters we want.
-.. code-block::
+.. plot::
+ :context:
+ :include-source:
import gudhi
f = open(gudhi.__root_source_dir__ + '/data/points/spiral_2d.csv', 'r')
@@ -22,30 +24,30 @@ As a by-product, we produce the persistence diagram of the merge tree of the ini
plt.scatter(data[:,0],data[:,1],marker='.',s=1)
plt.show()
-.. image:: img/spiral.png
-
-.. code-block::
+.. plot::
+ :context: close-figs
+ :include-source:
from gudhi.clustering.tomato import Tomato
t = Tomato()
t.fit(data)
t.plot_diagram()
-.. image:: img/spiral-diag.png
-
As one can see in `t.n_clusters_`, the algorithm found 6316 initial clusters. The diagram shows their prominence as their distance to the diagonal. There is always one point infinitely far: there is at least one cluster. Among the others, one point seems significantly farther from the diagonal than the others, which indicates that splitting the points into 2 clusters may be a sensible idea.
-.. code-block::
+.. plot::
+ :context: close-figs
+ :include-source:
t.n_clusters_=2
- plt.scatter(data[:,0],data[:,1],marker='.',s=1,c=["r" if i else "b" for i in t.labels_])
+ plt.scatter(data[:,0],data[:,1],marker='.',s=1,c=t.labels_)
plt.show()
-.. image:: img/spiral-color.png
-
Of course this is just the result for one set of parameters. We can ask for a different density estimator and a different neighborhood graph computed with different parameters.
-.. code-block::
+.. plot::
+ :context: close-figs
+ :include-source:
t = Tomato(density_type='DTM', k=100)
t.fit(data)
@@ -53,17 +55,15 @@ Of course this is just the result for one set of parameters. We can ask for a di
Makes the number of clusters clearer, and changes a bit the shape of the clusters.
-.. image:: img/spiral-diag2.png
-
A quick look at the corresponding density estimate
-.. code-block::
+.. plot::
+ :context: close-figs
+ :include-source:
plt.scatter(data[:,0],data[:,1],marker='.',s=1,c=t.weights_)
plt.show()
-.. image:: img/spiral-density.png
-
The code provides a few density estimators and graph constructions for convenience when first experimenting, but it is actually expected that advanced users provide their own graph and density estimates instead of point coordinates.
Since the algorithm essentially computes basins of attraction, it is also encouraged to use it on functions that do not represent densities at all.
diff --git a/src/python/doc/img/spiral-density.png b/src/python/doc/img/spiral-density.png
deleted file mode 100644
index a36cc882..00000000
--- a/src/python/doc/img/spiral-density.png
+++ /dev/null
Binary files differ
diff --git a/src/python/doc/img/spiral-diag.png b/src/python/doc/img/spiral-diag.png
deleted file mode 100644
index 018ef88d..00000000
--- a/src/python/doc/img/spiral-diag.png
+++ /dev/null
Binary files differ
diff --git a/src/python/doc/img/spiral-diag2.png b/src/python/doc/img/spiral-diag2.png
deleted file mode 100644
index fc5f2100..00000000
--- a/src/python/doc/img/spiral-diag2.png
+++ /dev/null
Binary files differ
diff --git a/src/python/doc/img/spiral.png b/src/python/doc/img/spiral.png
deleted file mode 100644
index 2d34a523..00000000
--- a/src/python/doc/img/spiral.png
+++ /dev/null
Binary files differ