From 299a62e6ec581e5095c9fdc73e454f35ed88f711 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 5 Jun 2020 23:05:34 +0200 Subject: Autogenerate the images when building the doc It does slow down building the doc significantly though. --- src/python/doc/clustering.rst | 32 ++++++++++++++++---------------- src/python/doc/img/spiral-density.png | Bin 442666 -> 0 bytes src/python/doc/img/spiral-diag.png | Bin 23621 -> 0 bytes src/python/doc/img/spiral-diag2.png | Bin 29403 -> 0 bytes src/python/doc/img/spiral.png | Bin 306629 -> 0 bytes 5 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 src/python/doc/img/spiral-density.png delete mode 100644 src/python/doc/img/spiral-diag.png delete mode 100644 src/python/doc/img/spiral-diag2.png delete mode 100644 src/python/doc/img/spiral.png (limited to 'src/python') 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 Binary files a/src/python/doc/img/spiral-density.png and /dev/null 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 Binary files a/src/python/doc/img/spiral-diag.png and /dev/null 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 Binary files a/src/python/doc/img/spiral-diag2.png and /dev/null differ diff --git a/src/python/doc/img/spiral.png b/src/python/doc/img/spiral.png deleted file mode 100644 index 2d34a523..00000000 Binary files a/src/python/doc/img/spiral.png and /dev/null differ -- cgit v1.2.3