Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用Seaborn通过分组条形图添加错误条形图_Python_Pandas_Matplotlib_Seaborn - Fatal编程技术网

Python 如何使用Seaborn通过分组条形图添加错误条形图

Python 如何使用Seaborn通过分组条形图添加错误条形图,python,pandas,matplotlib,seaborn,Python,Pandas,Matplotlib,Seaborn,我已经计算了数据帧的95%置信区间。使用Seaborn将其添加到分组条形图时,我收到一个错误,即yerr必须是标量或1D或(2,n)数组,如 Linguistic Measure ML Models score ci-b ci-t se 0 a RF 0.855 0.763 0.946 0.091 1 b RF 0.830 0.763

我已经计算了数据帧的95%置信区间。使用Seaborn将其添加到分组条形图时,我收到一个错误,即
yerr必须是标量或1D或(2,n)数组,如

   Linguistic Measure   ML Models   score   ci-b    ci-t    se
0     a                  RF         0.855   0.763   0.946   0.091
1     b                  RF         0.830   0.763   0.898   0.067
2     c                  RF         0.830   0.796   0.864   0.034
3     a                  SVM        0.841   0.823   0.860   0.018
4     b                  SVM        0.831   0.812   0.851   0.019
5     c                  SVM        0.835   0.820   0.850   0.015
6     a                  MLP        0.837   0.801   0.874   0.036
7     b                  MLP        0.810   0.721   0.900   0.089
8     c                  MLP        0.798   0.702   0.894   0.096
我使用下面的代码试图将错误条添加到分组的条形图中

# Draw a nested barplot 
g = sns.catplot(
    data=sample, kind="bar", #update df
    x="Linguistic Measure", y="score", hue="ML Models",
    yerr=sample.pivot(index='Linguistic Measure',columns='ML Models',values='se').values,
    ci=None, palette="BuPu", alpha=.6, height=5)

g.despine(left=True)
g.set_axis_labels("", "score")
g.legend.set_title("")
然后我得到下面的错误消息:

没有添加错误条,图表看起来很好

你看过这篇文章吗?