Don't forget about library updates
in
The Complete Data Visualization Course with Python, R, Tableau, and Excel
/
Scatter Plot - Python - How to Create a Scatter Plot
Remember to update the libraries to avoid errors with matplotlib and seaborn:
!pip install --upgrade matplotlib
!pip install --upgrade pandas
!pip install --upgrade seaborn
The code of the video also gives this warning:
FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
FutureWarning
It is therefore necessary to invert the first two arguments of scatterplot and to explicitly indicate the attributes x and y as follows:
plt.figure(figsize=(12, 8))
sns.scatterplot(x=df_real_estate["Area (ft.)"],
y=df_real_estate["Price"],
hue=df_real_estate["Building Type"],
palette=["black", "darkblue", "purple", "pink", "white"],
style=100)
plt.title("Relationship between Area and Price of California Real Estate",
fontsize=14,
weight="bold")
plt.xlabel("Area (sq. ft.)", weight="bold")
plt.ylabel("Price (000's of $)", weight="bold")
plt.show()
1 answers ( 0 marked as helpful)
That is very helpful! Thank you so much for sharing!! (: