如何更改Seaborn 0.9.0中的errorbar和cap厚度

2024-04-25 13:40:10 发布

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

我正在绘制多个方差分析研究,我希望我的误差条宽度和他们的上限厚度小于趋势线。当绘制带有误差条和上限的三向方差分析时,它可能会感到拥挤。我现在的情节是这样的: 3-Way Anova, uniform thickness

我的功能是:

sns.catplot(x="dose", y="somethings", hue="position", kind="point", 
        palette=sns.xkcd_palette(colors), capsize=.15, data=df, aspect=1.5)

我尝试过包含关键字,如lw_confhttps://github.com/mwaskom/seaborn/pull/898),但我不确定factorplot更改为catplot后,它的功能发生了什么变化。我还尝试过matplotlib中的errorbar关键字,例如,elinewidth和{}。Catplot似乎将capsize作为关键字参数,但我不知道它还可能使用其他关键字,也不知道{}发生了什么。任何关于关键字可能发生了什么的反馈,或是完成这项任务的新方法,我们将不胜感激。谢谢!在


Tags: 功能宽度绘制关键字hue趋势误差sns
1条回答
网友
1楼 · 发布于 2024-04-25 13:40:10

catplot向底层绘图函数传递额外的kwargs。因为您使用的是kind="point",所以绘图函数是sns.pointplot()The documentation for that function提到了参数:

errwidth : float, optional

Thickness of error bar lines (and caps).

因此,您只需在对catplot的调用中包含errwidth=

exercise = sns.load_dataset("exercise")
sns.catplot(x="time", y="pulse", hue="kind", kind="point", 
            capsize=.15, data=exercise, aspect=1.5, errwidth=0.5)

enter image description here

相关问题 更多 >