How to plot cdf in matplotlib in Python?

后端 未结 5 1617
粉色の甜心
粉色の甜心 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:21

    For an arbitrary collection of values, x:

    def cdf(x, plot=True, *args, **kwargs):
        x, y = sorted(x), np.arange(len(x)) / len(x)
        return plt.plot(x, y, *args, **kwargs) if plot else (x, y)
    

    ((If you're new to python, the *args, and **kwargs allow you to pass arguments and named arguments without declaring and managing them explicitly))

提交回复
热议问题