Search code examples
pythonpandasnumpyscipydata-analysis

Cumulative histogram over the frames


I had normalized data of histogram stored in separate files. How do I plot the cumulative histogram?

{Frame 1}(filename)
-1.114060000000000050e-01 0.000000000000000000e+00
-1.140599999999999947e-02 0.000000000000000000e+00
8.859400000000000608e-02 0.000000000000000000e+00
1.885940000000000394e-01 0.000000000000000000e+00
2.885940000000000172e-01 0.000000000000000000e+00
3.885939999999999950e-01 9.999999999999991118e+00
4.885940000000000838e-01 0.000000000000000000e+00
5.885940000000000616e-01 0.000000000000000000e+00
6.885940000000000394e-01 0.000000000000000000e+00 
7.885940000000000172e-01 0.000000000000000000e+00

Can someone give me idea how do I proceed? I look https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.cumfreq.html but didn't get any clue.

I used following code:

hist, bin_edges = n.histogram(a, density = True)

to generate this histogram files(normalized).


Solution

  • You can use plt.hist, which has both the argument density (which normalizes) and cumulative, to plot the cumulative histogram:

    plt.hist(a, density = True ,cumulative=True)
    plt.show()