Is there a way to do a grid with scatterplots from all columns from a dataframe, where Y is one of the dataframe columns?
I can do a for loop on either matplotlib
or seaborn
for this (see codes below), but I can't make them show on a grid.
I want them to be displayed in grid visualization to make it easier to compare them.
This is what I CAN do:
for col in boston_df:
plt.scatter(boston_df[col], boston_df["MEDV"], c="red", label=col)
plt.ylabel("medv")
plt.legend()
plt.show()
or
for col in boston_df:
sns.regplot(x=boston_df[col], y=boston_df["MEDV"])
plt.show()
Now if I try to create a subplot for example and use ax.scatter() in my loop like this
fig, ax = plt.subplots(3, 5,figsize=(16,6))
for col in boston_df:
ax.scatter(boston_df[col], boston_df["MEDV"], c="red", label=col)
plt.ylabel("medv")
plt.legend()
plt.show()
it gives me the error AttributeError: 'numpy.ndarray' object has no attribute 'scatter'
It would be beautiful to find some solution simple like this:
df.hist(figsize=(18,10), density=True, label=df.columns)
plt.show()