不指定`order 就可以使用barplot 函数吗?

Ste*_*eve 8 python jupyter-notebook

我正在研究基于这个 Kaggle kernel的 Titanic 数据集。在我尝试使用 barplot 函数的部分,它给了我一条警告消息UserWarning: Using the barplot function without specifying order,可能会产生不正确的绘图。

我应该担心吗?

我也尝试指定 order 参数和 Hue_order 。

grid = sns.FacetGrid(train_df, col='Embarked', row='Survived', height=2.2, aspect=1.6)
grid.map(sns.barplot, 'Sex', 'Fare', alpha=0.5, ci=None, order=[1,2,3], hue_order=['Embarked', 'Survived'])
grid.add_legend()
Run Code Online (Sandbox Code Playgroud)

当我指定 order 和 hue_order 时,它给了我空的条形图。 空条形图

但是,当我取出 order 和hue_order 时,它确实给了我带有以下警告消息的图:

C:\Users\user\Anaconda3\lib\site-packages\seaborn\axisgrid.py:715: UserWarning: Using the barplot function without specifying `order` is likely to produce an incorrect plot.
warnings.warn(warning)
Run Code Online (Sandbox Code Playgroud)

结果有错误警告

有什么我应该知道的想法或提示吗?提前致谢!

小智 3

我不确定如何使用 sns.Facetgrid 修复警告。您可以使用 catplot 来绘制完全相同的图。

这是我的代码:

g = sns.catplot(x="Sex", y='Fare', row="Embarked",
                   col='Survived', data=train_df,kind ='bar')
Run Code Online (Sandbox Code Playgroud)