如何在Matplotlib中获取一个反向累积直方图? 要在Matplotlib中获得一个反向累积直方图,我们可以在 hist() 方法中使用 cumulative = -1 。 设置图形大小并调整子图之间和周围的填充。 制作数据点列表。 用 data 和 cumulative = -1. 绘制直方图。 要显示图形,请使用 show() 方法。 示例 from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = [1, 2, 2, 3, 1, 4, 3, 0, 1, 3, 0] plt.hist(data, edgecolor='black', align="mid", cumulative=-1) plt.show() PythonCopy 输出