Python 在matplotlib中获取逆序累积直方图的技巧

Python 在matplotlib中获取逆序累积直方图的技巧,python,matplotlib,histogram,cumulative-frequency,Python,Matplotlib,Histogram,Cumulative Frequency,我想知道是否有(更好的)技巧来反转matplotlib中的累积直方图 假设我有一些分数在0.0到1.0之间,其中1.0是最好的分数。现在,我感兴趣的是绘制多少样本高于某个分数阈值 import numpy as np import matplotlib.pyplot as plt d = np.random.normal(size=1000) d = (d - d.min()) / (d.max() - d.min()) plt.hist(d, 50, histtype="stepfille

我想知道是否有(更好的)技巧来反转matplotlib中的累积直方图

假设我有一些分数在0.0到1.0之间,其中1.0是最好的分数。现在,我感兴趣的是绘制多少样本高于某个分数阈值

import numpy as np
import matplotlib.pyplot as plt

d = np.random.normal(size=1000)
d = (d - d.min()) / (d.max() - d.min())

plt.hist(d, 50, histtype="stepfilled", alpha=.7)


默认情况下,matplotlib将绘制累积直方图,如“样本数非常确定您可以在函数调用中使用
cumulative=-1

plt.hist(d, 50, histtype="stepfilled", alpha=.7, cumulative=-1)
从matplotlib hist()文档:

如果累计值小于0(例如,-1),则累积方向相反


请看第三个示例图像;我想这正是你想要的。

谢谢,这正是我想要的。
plt.hist(d-1, 50, histtype="stepfilled", alpha=.7, cumulative=True)
plt.hist(d, 50, histtype="stepfilled", alpha=.7, cumulative=-1)