def bars(pairs, dim, threshold): pairs = sorted(pairs) births = persistence.births(pairs, dim, threshold) deaths = persistence.deaths(pairs, dim, threshold) indexes = range(len(births)) lifetimes = list(deaths[i] - births[i] for i in indexes) return plt.bar(indexes, lifetimes, 1.0, births)
def deathsVersusBirthsHistogram(pairs, dim, threshold, nbins=100): pairs = [ p for p in pairs if p[1] < infinity ] births = persistence.births(pairs, dim, threshold) deaths = persistence.deaths(pairs, dim, threshold) axmin = min([min(births), min(deaths),0]) axmax = max([max(births), max(deaths), 0]) return plt.hist2d(births,deaths,[nbins,nbins],[[axmin,axmax],[axmin,axmax]],False,None,1,norm=col.LogNorm())
def weightsVersusPersistence(pairs, dim, threshold): births = persistence.births(pairs, dim, threshold) deaths = persistence.deaths(pairs, dim, threshold) spans = tuple(d - b for (b, d) in zip(births, deaths)) weights = persistence.weights(pairs, dim, threshold) if max(weights) > 0: return plt.semilogy(spans, weights, '.') else: return plt.plot(spans, weights, '.')
def deathsVersusBirthsHistogram(pairs, dim, threshold, nbins=100): pairs = [p for p in pairs if p[1] < infinity] births = persistence.births(pairs, dim, threshold) deaths = persistence.deaths(pairs, dim, threshold) axmin = min([min(births), min(deaths), 0]) axmax = max([max(births), max(deaths), 0]) return plt.hist2d(births, deaths, [nbins, nbins], [[axmin, axmax], [axmin, axmax]], False, None, 1, norm=col.LogNorm())
def deathsVersusBirths(pairs, dim, threshold): births = persistence.births(pairs, dim, threshold) deaths = persistence.deaths(pairs, dim, threshold) return plt.plot(births, deaths, '.')