예제 #1
0
def test_histogram_horizontal():
    bins, data = analysis.histogram_horizontal(sample_data_0,
                                               num_bins=11,
                                               min_bin=8.0,
                                               max_bin=10.0)
    nt.ok_(
        np.allclose(
            bins,
            np.array([8., 8.2, 8.4, 8.6, 8.8, 9., 9.2, 9.4, 9.6, 9.8, 10.])))
    nt.ok_(
        np.allclose(data, np.array([3., 3., 3., 3., 1., 3., 1., 1., 1., 1.])))
    bins, data = analysis.histogram_horizontal(sample_data_0, num_bins=10)
    nt.ok_(
        np.allclose(
            bins,
            np.array([
                8., 8.22222222, 8.44444444, 8.66666667, 8.88888889, 9.11111111,
                9.33333333, 9.55555556, 9.77777778, 10.
            ])))
    nt.ok_(np.allclose(data, np.array([3., 3., 3., 3., 3., 1., 1., 1., 1.])))
    bins, data = analysis.histogram_horizontal(sample_data_0,
                                               num_bins=4,
                                               min_bin=7.,
                                               max_bin=10.)
    nt.ok_(np.allclose(bins, np.array([7., 8., 9., 10.])))
    nt.ok_(np.allclose(data, np.array([0., 3., 1.])))
    bins, data = analysis.histogram_horizontal(sample_data_1,
                                               num_bins=4,
                                               min_bin=7.,
                                               max_bin=10.)
    nt.ok_(np.allclose(bins, np.array([7., 8., 9., 10.])))
    nt.ok_(np.allclose(data, np.array([1., 3., 1.])))
예제 #2
0
파일: plot.py 프로젝트: masht18/TMD
def histogram_horizontal(ph,
                         new_fig=True,
                         subplot=False,
                         bins=100,
                         color='b',
                         alpha=0.7,
                         **kwargs):
    '''Extracts and plots the binned histogram of a persistent
       homology array.
    '''
    fig, ax = _cm.get_figure(new_fig=new_fig, subplot=subplot)
    hist_data = analysis.histogram_horizontal(ph, num_bins=bins)
    ax.fill_between(hist_data[0][:-1],
                    0,
                    hist_data[1],
                    color=color,
                    alpha=alpha)

    return _cm.plot_style(fig=fig, ax=ax, **kwargs)