summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-08-17 13:32:41 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-08-17 13:32:41 +0000
commita5464d68d2848d21fc777809ab686b1bbf4e0139 (patch)
treee2449398baef124eeb97f72f20121fe231737310 /src
parent67ae5aa70e70097f72f868ebba1fa8e7ff96297d (diff)
Code review : Add a bw_method parameter to plot_persistence_density for the standard deviation of the Gaussian
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/plot_persistence_density_vincent@3799 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3bbc988434951bb429acd44b1f31f8310bb9ba9c
Diffstat (limited to 'src')
-rwxr-xr-xsrc/cython/cython/persistence_graphical_tools.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cython/cython/persistence_graphical_tools.py b/src/cython/cython/persistence_graphical_tools.py
index 0b3357f8..026e365d 100755
--- a/src/cython/cython/persistence_graphical_tools.py
+++ b/src/cython/cython/persistence_graphical_tools.py
@@ -223,7 +223,8 @@ try:
import math
def plot_persistence_density(persistence=[], persistence_file='',
- nbins=300, max_plots=1000, dimension=None,
+ nbins=300, bw_method=None,
+ max_plots=1000, dimension=None,
cmap=plt.cm.hot_r, legend=False):
"""This function plots the persistence density from persistence
values list or from a :doc:`persistence file <fileformats>`. Be
@@ -238,6 +239,14 @@ try:
:param nbins: Evaluate a gaussian kde on a regular grid of nbins x
nbins over data extents (default is 300)
:type nbins: int.
+ :param bw_method: The method used to calculate the estimator
+ bandwidth. This can be 'scott', 'silverman', a scalar constant
+ or a callable. If a scalar, this will be used directly as
+ kde.factor. If a callable, it should take a gaussian_kde
+ instance as only parameter and return a scalar. If None
+ (default), 'scott' is used. See scipy.stats.gaussian_kde
+ documentation for more details.
+ :type bw_method: str, scalar or callable, optional.
:param max_plots: maximal number of points to display. Selected points
are those with the longest life time. Set it to 0 to see all,
default value is 1000.
@@ -286,7 +295,7 @@ try:
plt.plot(x, x, color='k', linewidth=1.0)
# Evaluate a gaussian kde on a regular grid of nbins x nbins over data extents
- k = kde.gaussian_kde([birth,death])
+ k = kde.gaussian_kde([birth,death], bw_method=bw_method)
xi, yi = np.mgrid[birth.min():birth.max():nbins*1j, death.min():death.max():nbins*1j]
zi = k(np.vstack([xi.flatten(), yi.flatten()]))