I'm trying to create 9 scatterplots using a target variable and 9 continuous variables.
I couldn't figure out a way to loop over each axis to plot scatterplots of each continuous variable against the target.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
fig, ax = plt.subplots(nrows=5, ncols=3, figsize=(16, 8))
sns.scatterplot(x=df['cont0'], y=df['target'], ax=ax[0, 0])
sns.scatterplot(x=df['cont1'], y=df['target'], ax=ax[0, 1])
sns.scatterplot(x=df['cont2'], y=df['target'], ax=ax[0, 2])
sns.scatterplot(x=df['cont3'], y=df['target'], ax=ax[1, 0])
sns.scatterplot(x=df['cont4'], y=df['target'], ax=ax[1, 1])
sns.scatterplot(x=df['cont5'], y=df['target'], ax=ax[1, 2])
sns.scatterplot(x=df['cont6'], y=df['target'], ax=ax[2, 0])
sns.scatterplot(x=df['cont7'], y=df['target'], ax=ax[2, 1])
sns.scatterplot(x=df['cont8'], y=df['target'], ax=ax[2, 2])
How can I do this more efficiently?