How to plot cdf in matplotlib in Python?

后端 未结 5 1615
粉色の甜心
粉色の甜心 2020-12-14 08:51

I have a disordered list named d that looks like:

[0.0000, 123.9877,0.0000,9870.9876, ...]

I just simply want to plot a cdf gr

5条回答
  •  抹茶落季
    2020-12-14 09:42

    I know I'm late to the party. But, there is a simpler way if you just want the cdf for your plot and not for future calculations:

    plt.hist(put_data_here, normed=True, cumulative=True, label='CDF',
             histtype='step', alpha=0.8, color='k')
    

    As an example,

    plt.hist(dataset, bins=bins, normed=True, cumulative=True, label='CDF DATA', 
             histtype='step', alpha=0.55, color='purple')
    # bins and (lognormal / normal) datasets are pre-defined
    

    EDIT: This example from the matplotlib docs may be more helpful.

提交回复
热议问题