- 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.
推薦閱讀
- 微服務(wù)與事件驅(qū)動架構(gòu)
- Python從入門到精通(精粹版)
- Hadoop+Spark大數(shù)據(jù)分析實(shí)戰(zhàn)
- 表哥的Access入門:以Excel視角快速學(xué)習(xí)數(shù)據(jù)庫開發(fā)(第2版)
- Getting Started with Laravel 4
- Extreme C
- 軟件工程基礎(chǔ)與實(shí)訓(xùn)教程
- 零基礎(chǔ)輕松學(xué)C++:青少年趣味編程(全彩版)
- Java高級程序設(shè)計
- 企業(yè)級Java現(xiàn)代化:寫給開發(fā)者的云原生簡明指南
- Getting Started with the Lazarus IDE
- 基于Docker的Redis入門與實(shí)戰(zhàn)
- 零基礎(chǔ)入門學(xué)習(xí)C語言:帶你學(xué)C帶你飛
- Getting Started with SQL Server 2014 Administration
- 自然語言處理NLP從入門到項(xiàng)目實(shí)戰(zhàn):Python語言實(shí)現(xiàn)