- 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.
推薦閱讀
- vSphere High Performance Cookbook
- Microsoft Dynamics 365 Extensions Cookbook
- JavaScript+jQuery開發實戰
- 編譯系統透視:圖解編譯原理
- Android底層接口與驅動開發技術詳解
- VMware虛擬化技術
- R Data Analysis Cookbook(Second Edition)
- Unity 2D Game Development Cookbook
- Domain-Driven Design in PHP
- 從零開始:UI圖標設計與制作(第3版)
- Anaconda數據科學實戰
- Android技術內幕(系統卷)
- Spark技術內幕:深入解析Spark內核架構設計與實現原理
- R語言編程基礎
- Java EE應用開發及實訓