gpt4 book ai didi

python - Matplotlib 累积图

转载 作者:太空宇宙 更新时间:2023-11-04 08:01:29 25 4
gpt4 key购买 nike

我应该使用什么 matplotlib 函数来创建这样的“上方”图?

我试图在 gallery 中找到它,但我没能做到。

enter image description here

最佳答案

你可以使用 matplotlib fill_between,例如,

#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0.0, 2, 0.1)
y = 10*np.ones(x.shape[0])
c = ['r', 'b', 'g', 'y', 'k']
fig, ax = plt.subplots()
for i in range(5):
r = np.random.randn(x.shape[0])
yp = np.copy(y)
y = y + np.cumsum(np.abs(r))
ax.fill_between(x, yp, y, color=c[i], alpha=0.5)

plt.show()

看起来, enter image description here

关于python - Matplotlib 累积图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39332553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com