小编Ste*_*eve的帖子

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

我正在研究基于这个 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)

结果有错误警告

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

python jupyter-notebook

8
推荐指数
1
解决办法
1623
查看次数

标签 统计

jupyter-notebook ×1

python ×1