如何在 Matplotlib 中获取逆序累积直方图?
pythonserver side programmingprogramming更新于 2025/8/7 13:00:17
要在 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()
输出

相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

