在折线图上绘制错误阴影带 - python

2024-04-19 15:41:58 发布

您现在位置:Python中文网/ 问答频道 /正文

假设我有25行这样:

x = np.linspace(0, 30, 60)
y = np.sin(x/6*np.pi)
error = np.random.normal(0.1, 0.02, size=y.shape)
y1 = y+ np.random.normal(0, 0.1, size=y.shape)
y2= y+ np.random.normal(0, 0.1, size=y.shape)
plt.plot(x, y, 'k-')
plt.plot(x, y1, 'k-')
plt.plot(x, y2,'k-')
.
.
.

现在,我想画一个这样的情节:enter image description here。如何自动生成这些误差线,并使着色只给出一堆线,所有线都具有相同的整体形状,但略有变化。你知道吗


Tags: sizeplotnppipltrandomerrorsin