将自定义误差线添加到 seaborn regplot 和 residplot [英] Add custom error bars to seaborn regplot and residplot

查看:73
本文介绍了将自定义误差线添加到 seaborn regplot 和 residplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法像使用 yerr 使用 matplotlib errorbar 那样向 seaborn regplot 和 residplot 添加自定义误差条?例子在这里;如果我只是添加一个 yerr 参数会发生错误,

Is there a way to add custom error bars to seaborn regplot and residplot like one can do with matplotlib errorbar using yerr? Examples are here; if I just add a yerr argument an error occurs,

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

Draw the errorbars using matplotlib's 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')

这篇关于将自定义误差线添加到 seaborn regplot 和 residplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆