0

pls, how do I visualize multiple independent variable against a single dependent variable in a single scatter plot in python. I tried doing it like this :

plt.scatter(df[["Bedroom","Bathroom,"Building_Size","Plot_of_Land"], df["Price"])

But it didn't work

/

1 Answers1

0
relevant_cols = ["Bedroom", "Bathroom", "Building_Size", "Plot_of_Land"]
x_min, x_max = df[relevant_cols].min().min() - 1, df[relevant_cols].max().max() + 1

_, ax = plt.subplots()
for column, colour in zip(relevant_cols, ["tab:orange", "tab:blue", "tab:green", "tab:red"]):
    df.plot(x=column, y='price', kind='scatter', ax=ax, color=colour,
            label=column, ylabel='', xlim=(x_min, x_max))
Josh Friedlander
  • 10,870
  • 5
  • 35
  • 75