Pythoner
Pythoner

Reputation: 5585

How to plot seaborn pairplot as subplot?

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.

Upvotes: 1

Views: 5079

Answers (2)

Justinas
Justinas

Reputation: 21

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.

Upvotes: 2

Pythoner
Pythoner

Reputation: 5585

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

Upvotes: 0

Related Questions