plt.subplot 制作空图
plt.subplot make empty plot
我想输入 2 个表格以适应 1 行和 2 列
所以我设置子图 (1, 2) 但显示 (2, 2) 形状为空图
(我使用带有 %matplotlib inline
的 Jupyter 笔记本)
我该如何解决?
f,ax=plt.subplots(1,2,figsize=(20,8))
sns.barplot('SibSp','Survived',data=train, ax=ax[0])
ax[0].set_title('SibSp vs Survived')
sns.factorplot('SibSp','Survived',data=train, ax=ax[1])
ax[1].set_title('SibSp vs Survived')
plt.show()
factorplot
函数在 Seaborn 中已重命名为 catplot
。
但我认为 catplot
不接受轴参数(虽然不确定)。
最简单的方法是使用 pointplot
而不是 factorplot
。
f,ax=plt.subplots(1,2,figsize=(20,8))
sns.barplot('SibSp','Survived',data=train, ax=ax[0])
ax[0].set_title('SibSp vs Survived')
sns.pointplot('SibSp','Survived',data=train, ax=ax[1])
ax[1].set_title('SibSp vs Survived')
plt.show()
我想输入 2 个表格以适应 1 行和 2 列
所以我设置子图 (1, 2) 但显示 (2, 2) 形状为空图
(我使用带有 %matplotlib inline
的 Jupyter 笔记本)
我该如何解决?
f,ax=plt.subplots(1,2,figsize=(20,8))
sns.barplot('SibSp','Survived',data=train, ax=ax[0])
ax[0].set_title('SibSp vs Survived')
sns.factorplot('SibSp','Survived',data=train, ax=ax[1])
ax[1].set_title('SibSp vs Survived')
plt.show()
factorplot
函数在 Seaborn 中已重命名为 catplot
。
但我认为 catplot
不接受轴参数(虽然不确定)。
最简单的方法是使用 pointplot
而不是 factorplot
。
f,ax=plt.subplots(1,2,figsize=(20,8))
sns.barplot('SibSp','Survived',data=train, ax=ax[0])
ax[0].set_title('SibSp vs Survived')
sns.pointplot('SibSp','Survived',data=train, ax=ax[1])
ax[1].set_title('SibSp vs Survived')
plt.show()