mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.62k stars 1.94k forks source link

errorbar wont be plotted if using 'col' #3674

Closed ohadOrbach closed 7 months ago

ohadOrbach commented 7 months ago

using next command sns.catplot(data=df, x=x, y=y, hue=hue, kind='bar', height=6, aspect=1) will display error bars

sns.catplot(data=df, x=x, y=y, hue=hue, col=col, kind='bar', height=6, aspect=1) or with some variations like adding errorbar=('ci', 98) will not display error bars

temetski commented 7 months ago

@ohadOrbach You do not provide a sample data for context. Perhaps the problem is in your data rather than seaborn. Using this example:

import seaborn as sns

df = sns.load_dataset("tips")
sns.catplot(data=df, x="sex", y="tip", kind='bar', height=6, aspect=1)
sns.catplot(data=df, x="sex", y="tip", col='size', kind='bar', height=6, aspect=1)

You should immediately see that error bars do appear even in the case where col is used. If no error bars form, it can be the case that

  1. df only contains 1 data point for the combination of x, col
  2. df contains multiple datapoints, but the variation is so miniscule that no visible error bar is produced.