0

I would like to input 2 tables to fit in 1 row and 2 columns so I set subplots (1, 2) but show (2, 2) shape with empty plots (I use Jupyter notebook with %matplotlib inline)

How can I solve it?

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()

enter image description here

DavidG
  • 24,279
  • 14
  • 89
  • 82
  • `factorplot` creates its own figure and axes. You might instead want to use a [`pointplot`](https://seaborn.pydata.org/generated/seaborn.pointplot.html) as described in [this question](https://stackoverflow.com/questions/33925494/seaborn-produces-separate-figures-in-subplots) – DavidG Sep 14 '20 at 08:16

1 Answers1

0

The factorplot function has been renamed to catplot in Seaborn. But I think catplot doesn't take axes argument(not sure though).

The easiest way out is to use pointplot instead of 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()
Arnab
  • 50
  • 5