有没有一种方法可以将自定义错误栏添加到seaborn regplot和residplot中,就像使用yerr对matplotlib错误栏所做的那样?例子在这里;如果我只是添加 yrr 参数就会发生错误,
import seaborn as sns xd = [1,2,3,4,6,7] yd = [2,4,7,9,12,14] yerrd = [1,2,1,3,1,4] sns.regplot(xd, yd) sns.residplot(xd, yd)
使用 matplotlib 绘制误差线errorbar
errorbar
xd = [1,2,3,4,6,7] yd = [2,4,7,9,12,14] yerrd = [1,2,1,3,1,4] fig, ax = plt.subplots() sns.regplot(xd, yd, ax=ax) ax.errorbar(xd, yd, yerr=yerrd, fmt='none', capsize=5, zorder=1, color='C0')