我正在尝试绘制看起来平滑的置信区间的折线图。看起来像这样:
当前,我所做的是使用误差线显示置信区间。因此,我有100(x,y)对,并将其传递给sns.lineplot
,它会为我创建一条线,然后在这些点的每一个中,我都有要绘制Sigma_new_vec
的标准偏差。>
axs[(e-1)//2, (e-1)%2].errorbar(x, y ,yerr = Sigma_new_vec, linestyle="None")
sns.lineplot(x='x', y='y', data = predicted_line, ax= axs[(e-1)//2, (e-1)%])
sns.lineplot(x='x', y='y', data = true_line, ax = axs[(e-1)//2, (e-1)%2] )
答案 0 :(得分:1)
有了@ImportanceOfBeingErnest's的建议,我成功了!
lower_bound = [M_new_vec[i] - Sigma_new_vec[i] for i in range(len(M_new_vec))]
upper_bound = [M_new_vec[i] + Sigma_new_vec[i] for i in range(len(M_new_vec))]
plt.fill_between(x_axis, lower_bound, upper_bound, alpha=.3)