AttributeError: 'PathCollection' object has no property 'errorbar'

113 Views Asked by At

I am trying to add the confidence interval 95% on my graph. This code works just fine:

sns.catplot(data=df, x="read_level_1", y="sum_START", kind="box")

However, when I try the following line:

sns.catplot(data=df, x="read_level_1", y="sum_START", errorbar=("ci", 95))

It doesn't work, and I keep getting the following error:

AttributeError: 'PathCollection' object has no property 'errorbar'

Any advice, please?

2

There are 2 best solutions below

0
Marcin Orlowski On

You can replace use of non-existing errorbar with kind and ci arguments respectively. So instead of:

sns.catplot(data=df, x="read_level_1", y="sum_START", errorbar=("ci", 95))

write:

sns.catplot(data=df, x="read_level_1", y="sum_START", kind="bar", ci=95)

BUT... ci seems to be marked deprecated, so I'd rather go for barplot() instead:

sns.barplot(data=df, x="read_level_1", y="sum_START", ci=95)
0
mwaskom On

The default kind for catplot is strip but only two kinds (bar and point) can show error bars and, hence, accept the errorbar parameter to control what is shown. A 95% CI is the default value for both so you just need to add kind="point" to your call.