- Hands-On Exploratory Data Analysis with Python
- Suresh Kumar Mukhiya Usman Ahmed
- 136字
- 2021-06-24 16:44:52
Scatter plot using seaborn
A scatter plot can also be generated using the seaborn library. Seaborn makes the graph visually better. We can illustrate the relationship between x and y for distinct subsets of the data by utilizing the size, style, and hue parameters of the scatter plot in seaborn.
Get more detailed information about the parameters from seaborn's documentation website: https://seaborn.pydata.org/generated/seaborn.scatterplot.html.
Now, let's load the Iris dataset:
df = sns.load_dataset('iris')
df['species'] = df['species'].map({'setosa': 0, "versicolor": 1, "virginica": 2})
sns.scatterplot(x=df["sepal_length"], y=df["sepal_width"], hue=df.species, data=df)
The scatter plot generated from the preceding code is as follows:
In the preceding plot, we can clearly see there are three species of flowers indicated by three distinct colors. It is more clear from the diagram how different specifies of flowers vary in terms of the sepal width and the length.
推薦閱讀
- 深入淺出Java虛擬機:JVM原理與實戰
- ASP.NET Core Essentials
- Python深度學習
- Blockly創意趣味編程
- MongoDB權威指南(第3版)
- 利用Python進行數據分析(原書第3版)
- JavaCAPS基礎、應用與案例
- MySQL入門很輕松(微課超值版)
- Learning Material Design
- Android應用開發實戰(第2版)
- Practical Predictive Analytics
- 青少年學Python(第2冊)
- JavaScript編程精解(原書第2版)
- HTML5 Game Development by Example:Beginner's Guide(Second Edition)
- MATLAB從入門到精通