小编chr*_*a93的帖子

matplotlib中不需要的空白子图

情节

我是matplotlib和seaborn的新手,目前正在尝试使用经典的titanic数据集练习这两个库。这可能是基本的,但是我试图通过输入参数ax = matplotlib axis来并排绘制两个因子图,如以下代码所示:

import matploblib.pyplot as plt
import seaborn as sns
%matplotlib inline 

fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.factorplot(x='Pclass',data=titanic_df,kind='count',hue='Survived',ax=axis1)
sns.factorplot(x='SibSp',data=titanic_df,kind='count',hue='Survived',ax=axis2)
Run Code Online (Sandbox Code Playgroud)

我原本期望两个因子图同时出现,但不仅如此,我还获得了两个额外的空白子图,如上所示

编辑:图像不存在

python matplotlib seaborn

4
推荐指数
1
解决办法
1878
查看次数

标签 统计

matplotlib ×1

python ×1

seaborn ×1