how to create multiple subplots( scatterplot) in for loop I want to create scatterplot of target variable with all the other variables in dataframe. Just like we create pairplot but as pairplot with large number of variables will take lot of time and computing memory, it is required to draw scatter plot containing all the variables with target variable.
So tried implementing it in for loop, but only last one got rendered properly.
count=1
for i in df.columns:
    plt.subplot(n,1,count)
    plt.figure(figsize=[5,5])
    sns.scatterplot(df[&quot;cnt&quot;],df[i])
    count+=1

output: only last plot is rendered properly
Just get rid of the plt.figure(figsize=[5,5])
count=1
for i in df.columns:
    plt.subplot(n,1,count)
    sns.scatterplot(df[&quot;cnt&quot;],df[i])
    count+=1

plt.show()

or use this to make it more beautier (Adjust the first two parameters of subplot function, i.e. 3, 2, to if you have more columns. First parameter specifies the number of rows for subplots in the plot, and second parameter specifies number of columns)
count=1
plt.subplots(figsize=(10, 8))
for i in df.columns:
    plt.subplot(3,2,count)
    sns.scatterplot(df[&quot;cnt&quot;],df[i])
    count+=1

plt.show()