0

I have the following code to generate 3 PairPlots, each one with a single ax:

sns.pairplot(df, x_vars="Agricultural area", y_vars="Wooded area", hue="Elevation")
sns.pairplot(df, x_vars="Agricultural area", y_vars="Settlement area", hue="Elevation")
sns.pairplot(df, x_vars="Agricultural area", y_vars="Unproductive area", hue="Elevation")

plt.show()

This works, but it generates 3 distinct figures. I now would like to have the result in the same figure, for example using this:

fig, axes = plt.subplots(1, 3, sharey=True, figsize=(15, 10))

Then adding PairGrid[0],[0] to the first ax (axes[0]) and so on. There is no ax parameter in pairplot which I guess is normal as it returns a grid, not an ax. Is this possible (how)? Else is there a better solution to achieve this?

evilmandarine
  • 4,241
  • 4
  • 17
  • 40

1 Answers1

0

Got it:

sns.pairplot(
    df,
    x_vars=["Wooded area", "Settlement area", "Unproductive area"],
    y_vars="Agricultural area",
    hue="Elevation",
)
evilmandarine
  • 4,241
  • 4
  • 17
  • 40