小编cra*_*egg的帖子

Seaborn因子图自定义误差条

我想在seaborn中绘制一个factorplot但是手动提供误差条而不是让seaborn计算它们.

我有一个大致如下的pandas数据框:

     model output feature  mean   std
0    first    two       a  9.00  2.00
1    first    one       b  0.00  0.00
2    first    one       c  0.00  0.00
3    first    two       d  0.60  0.05
...
77   third   four       a  0.30  0.02
78   third   four       b  0.30  0.02
79   third   four       c  0.10  0.01
Run Code Online (Sandbox Code Playgroud)

我正在输出一个看起来大致如下的情节: seaborn bar情节

我正在使用这个seaborn命令来生成图:

g = sns.factorplot(data=pltdf, x='feature', y='mean', kind='bar',
                   col='output', col_wrap=2, sharey=False, hue='model')
g.set_xticklabels(rotation=90)
Run Code Online (Sandbox Code Playgroud)

但是,我无法弄清楚如何让seaborn使用'std'列作为错误栏.不幸的是,重新计算相关数据框的输出将非常耗时.

这有点类似于这个问题: 使用Seaborn FacetGrid从数据框中绘制错误条

除了我无法弄清楚如何使用matplotlib.pyplot.bar函数.

有没有办法使用seaborn factorplotFacetGrid与matplotlib结合使用?

谢谢!

python plot matplotlib pandas seaborn

13
推荐指数
1
解决办法
8231
查看次数

标签 统计

matplotlib ×1

pandas ×1

plot ×1

python ×1

seaborn ×1