平滑matplotlib中的错误线

2024-04-26 21:39:06 发布

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

我有一些误差线,我把它们做成了一条误差线,像这样:

cis = []
for row in data:
    cis.append(stats.norm.interval(0.95, loc=np.mean(row), scale=np.std(row)))

ci_lower = [ci[0] for ci in cis]
ci_upper = [ci[1] for ci in cis]
cis = [ci_lower, ci_upper]

offsets = np.abs(cis - y[None, :])

plt.fill_between(x, y - offsets[0], y + offsets[1], facecolor=(0.8, 0.8, 0.8))
plt.errorbar(x, y, yerr=offsets, color=(0.8, 0.8, 0.8))
plt.plot(x, y, 'k', linewidth=3)
plt.show()

它工作得很好,除了我想平滑至少错误线-它目前看起来相当锯齿-但不知道从哪里开始。你知道吗


Tags: incinormfordatastatsnpplt