1

I use the following to create my subplots

fig, axs = plt.subplots(2,2)
sns.plotfunc(..., ax = axs[0])

but, the pairplot function in seaborn does not support the ax augment, any idea how to plot it as subplot?

Thanks in advance.

Pythoner
  • 5,265
  • 5
  • 33
  • 49
  • Possible duplicate of [Plotting with seaborn using the matplotlib object-oriented interface](https://stackoverflow.com/questions/23969619/plotting-with-seaborn-using-the-matplotlib-object-oriented-interface) – ImportanceOfBeingErnest Jan 08 '19 at 08:58

2 Answers2

2

You can use Seaborn's PairGrid to plot multiple pairplots like this:

g = sns.PairGrid(df, y_vars=['variable_a','variable_b'], x_vars=["variable_c", "variable_d"], height=4)
g.map(sns.regplot)
plt.show()

Another example on how to use PairGrid can be found here.

Justinas
  • 21
  • 3
0

Actually, if I passed plt.subplots(2, 2), it will return 2*2 array, thus I should use sns.plotfunc(..., ax = axs[0][1]), instead

Pythoner
  • 5,265
  • 5
  • 33
  • 49